Create Sub Folder in Directory using C#.net

Naraayanan
Posted by Naraayanan under C# category on | Points: 40 | Views : 5095
 public static string fname;
public static string Path;
public static string fldname;
public static bool mess;

public static bool createFolder(string sPath, string foldername)
{
#region Check folder Name
bool chkTool = Directory.Exists(sPath);
if (chkTool)
{
fname = @"\" + foldername + "\\";
fname = sPath + fname;
Directory.CreateDirectory(fname);
mess = true;
}
else if (!chkTool)
{
if (!Directory.Exists(sPath))
{
Directory.CreateDirectory(sPath);
}
fname = @"\" + foldername + "\\";
fname = sPath + fname;
Directory.CreateDirectory(fname);
mess = true;
}
#endregion Check folder Name
return mess;

}
Path = @"E:\Test";
fldname = "Test1";
bool chk = createFolder(Path, fldname);
if (chk)
{
MessageBox.Show("Folder Created");
}
else
{
MessageBox.Show("Folder is not Create");
}

Comments or Responses

Login to post response