本文介绍了如何在c#中重命名文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在c#中重命名文件?请回复

How to rename a file in c#?? Please do reply

推荐答案

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#中重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 13:34
查看更多