Tuesday, February 7, 2012

Rename a file in ASP.Net

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);


No comments:

Post a Comment