Copy Code code as follows:
/delete folder, parameter folder path
protected void DeleteDirectory (String Dir,bool deletesubdir)
{
Try
{
Directory.delete (dir, deletesubdir);
}
catch (Exception e)
{
Logger. Error ("DeleteDirectory Error dir =" + dir, E);
throw new Exception ("deletedirectory Error dir =" + dir, E);
}
}
Delete path, enter parameter, file path
protected void DeleteFile (String dir)
{
Try
{
File.delete (dir);
}
catch (Exception e)
{
Logger. Error ("DeleteDirectory Error dir =" + dir, E);
throw new Exception ("deletedirectory Error dir =" + dir, E);
}
}
Create a folder from a parameter
protected void CreateDirectory (String dir)
{
Try
{
if (Directory.Exists (dir))
{
Logger. Warning ("This direcotry is exists dir =" + dir);
Return
}
Directory.CreateDirectory (dir);
}
catch (Exception e)
{
Logger. Error ("Createdicectory error dir =" + dir, E);
throw new Serversystemexception ("createdicectory Error dir =" + dir, E);
}
}