开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜