Suddenly think of it, so think about it.
Remember that there is no rename in the C # file class, so a lot of the online use is move MoveTo copy+delete and so on these methods
In fact, although the above method can realize the function but it always seems that the egg hurts
Today, Baidu suddenly found an authentic solution
Think carefully about the method of My.Computer.FileSystem.RenameFile in vb.net but how to use it in C #?? It's really simple, just the following steps.
1. Add references First: Microsoft.VisualBasic, plus using Microsoft.VisualBasic.Devices;
2. On the following two lines
Computer MyComputer = new computer ();
MyComputer.FileSystem.RenameFile (FileName, NewFileName);
where filename is the full path of the file you want to rename, NewFileName is just the target file name;
Oh, it looks pretty simple.
The above content is from: http://blog.csdn.net/wenjunsu/article/details/5820634
C # Renaming files (authentic method)