如何在c#中重命名文件 [英] How to rename a file in c#
本文介绍了如何在c#中重命名文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在c#中重命名文件?请回复
How to rename a file in c#?? Please do reply
推荐答案
我们可以使用File类的静态Move方法
we can use the static Move method of the File class
using System;
using System.IO;
class nAmeChange
{
public static void Main()
{
string oldName=@"D:\old.txt";//File path name
string newName=@"D:\new.txt";
RenameFile(oldName,newName);
}
//This code has the effect of renaming the originalName file to newName.
public static void RenameFile(string originalName, string newName)
{
File.Move(originalName, newName);
Console.WriteLine("Success..!!");
}
}
请参阅分步教程的链接:如何用c#重命名文件
这里:http://msdn.microsoft.com/en-us/library /system.io.file.move%28v=vs.110%29.aspx [ ^ ]。
请阅读我的评论这个问题。答案不是你真正需要的。
-SA
你试过吗? google?
参考: - C#.net中的文件重命名 [ ^ ]
这可能会有所帮助
Have you tried google?
Refer:-File Rename in C#.net[^]
This may help
这篇关于如何在c#中重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文