c# 文件(夾)創(chuàng)建與刪除
更新時間:2009年07月25日 10:22:34 作者:
刪除文件夾,參數(shù)文件夾路徑
復制代碼 代碼如下:
/刪除文件夾,參數(shù)文件夾路徑
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);
}
}
//刪除路徑,輸入?yún)?shù),文件路徑
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);
}
}
//根據(jù)參數(shù)創(chuàng)建文件夾
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);
}
}
相關(guān)文章
C# 總結(jié)QueueUserWorkItem傳參幾種方式案例詳解
這篇文章主要介紹了C# 總結(jié)QueueUserWorkItem傳參幾種方式案例詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下2021-09-09
深入探討C#中的const、readonly關(guān)鍵字
這篇文章主要介紹了深入探討C#中的const、readonly關(guān)鍵字,本文可以幫助你深刻理解這兩個關(guān)鍵字,而且是面試中最可能面試到的問題哦,需要的朋友可以參考下2014-08-08
Unity UGUI的RectMask2D遮罩組件的介紹使用
這篇文章主要為大家介紹了Unity UGUI的RectMask2D遮罩組件的介紹使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-07-07
C#異步迭代IAsyncEnumerable應(yīng)用實現(xiàn)
IAsyncEnumerable可以來實現(xiàn)異步迭代,本文就主要介紹了C#異步迭代IAsyncEnumerable應(yīng)用實現(xiàn),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-06-06

