How to leave a copy of the original file when we save the file
When modifying and saving a file, h开发者_运维问答ow to leave a copy of the original file, say give it *.bak?Is there a built-in support?
You could use the .NET framework to simply copy the file to a .bak and then modify the original.
You can call File.Move
to rename the original file, then save the new version with the original name.
Here is a short example:
// This is the current file
string filePath = @"C:\temp\test.txt";
//Now change file extension to text.bak
string filePathBak = Path.ChangeExtension(filePath, "bak");
// Save orginal file
File.Move(filePath, filePathBak);
精彩评论