void MoveFile1() {
string fileToMove = @"c:\temp\New Text Document.txt";
string fileNewDestination = @"c:\temp\test.txt";
if (File.Exists(fileToMove) && !File.Exists(fileNewDestination)) {
File.Move(fileToMove, fileNewDestination);
}
}
void MoveFile2() {
string fileToMove = @"c:\temp\New Text Document.txt";
string fileNewDestination = @"c:\temp\test.txt";
FileInfo file = new FileInfo(fileToMove);
if (file.Exists) {
file.MoveTo(fileNewDestination);
}
}
File类和FileInfo类来演示如何移动文件
最新推荐文章于 2024-08-02 15:59:37 发布