Monday 7 November 2011

How to rename directory in .Net

There is no separate method for renaming the folders in c#.Net. But you can achieve this by using Move method which is in Directory class.
Note: using System.IO namespace.
string path = System.Configuration.ConfigurationSettings.AppSettings["Path"].ToString();
string Fromfolder;
string Tofolder; Fromfolder ="\\"+Fromfolder+"\\";
Tofolder = "\\"+Tofolder+"\\";
Directory.Move(path + Fromfolder, path + Tofolder);

No comments:

Post a Comment