Saturday, March 16, 2013

Rename Files in C#.NET


There is no separate method for renaming files in .NET. For the purpose of renaming files we can use MOVE() method as in below example

string path = "~/Tiles/";
string FromFile = path+"old.jpg";
string ToFile = path + "new.jpg";
if (File.Exists(Server.MapPath(FromFile)))
File.Move(Server.MapPath(FromFile), Server.MapPath(ToFile));

No comments:
Write comments
Recommended Posts × +