I know the method Directory.Move(source, destination)
to rename a folder. But when I rename the desitnation folder with the ~
symbol at the begin, there is error.
System.NotSupportedException: The given path's format is not supported.
Here is my code:
string oldFolderPath = @"C:\Old";
string newFolderPath = "~" + oldFolderPath;
Directory.Move(oldFolderPath, newFolderPath);
In the System.IO.Path.InvalidPathChars
, the following characters are invalid:
" < > |
It does not list tilde symbol, so how can I do? Thank you very much.