Rename a file in ASP.Net using C#
Unfortunately C# does not provide any method for
file renaming. The below trick you can use to rename a file.Use the namespace
to file handling purpose.
Using System.io;- Just copy the file with other filename
- Then delete the old file
protected
void Page_Load(object
sender, EventArgs e)
{
string
oldf = "D:\\hello.txt";
string
newf = "D:\\jello.txt";
File.Copy(oldf,
newf);
File.Delete(oldf);
}
No comments:
Post a Comment