Friday 14 October 2011

Replacing special characters while creating directory or file

When we are creating directory in windows it could not accept the spacial character for directory name.
If folder name string is dynamic( we don't know which string it is) then we need to write the spacial character from that string. To repalce special characrers while creating directory as follows(this step must be added if we don't confirm that string)
directoryname=System.Text.RegularExpressions.Regex.Replace(directoryname,@"[*?:\|<>\\/]", "-");

No comments:

Post a Comment