首先import System.IO
利用以下code:
//Renaming a File in C# protected void btnRenameFile_Click(object sender, EventArgs e) { string path = Server.MapPath("~") + "\\test\\"; string Fromfile = path + "FileLength.txt"; string Tofile = path + "FileLength1.txt"; File.Move(Fromfile, Tofile); } //Rename a Folder in C# protected void btnRenameFolder_Click(object sender, EventArgs e) { string path = Server.MapPath("~") ; string Fromfol = "\\test\\"; string Tofol = "\\test1\\"; Directory.Move(path + Fromfol, path + Tofol); }
沒有留言:
張貼留言