刪除資料夾的檔案

2021-09-25 16:00:48 字數 837 閱讀 6201

儲存資料很多時候要儲存檔案,儲存檔案用路徑的形式檔案,就要把檔案儲存到你的專案裡,查詢時通過資料庫裡儲存的路徑訪問檔案

儲存了檔案就要刪除

查詢出資料庫的檔案路徑,提取資料庫的路徑,通過正則匹配、拼接出檔案所在路徑,然後刪除檔案

如果沒有where tbmarketactivity.marketactivityid == marketactivityid && tbmarketactivity.consultdata != null這個條件,你儲存的時候沒有儲存檔案,正則匹配就匹配不了,就會資料異常

//===查詢出附件不等於null的資料

listdbfiles = (from tbmarketactivity in mymodels.b_marketactivity

where tbmarketactivity.marketactivityid == marketactivityid && tbmarketactivity.consultdata != null

select tbmarketactivity).tolist();

//刪除檔案

foreach (b_marketactivity bmarketactivity in dbfiles)

catch (exception e)

}

沒有刪除之前的

刪除之後的

檔案 資料夾刪除

今天恰好用到檔案刪除,上網看到了乙份整理不錯的,分享下。1,驗證傳入路徑是否為正確的路徑名 windows系統,其他系統未使用 驗證字串是否為正確路徑名的正規表示式 private static string matches a za z 通過 spath.matches matches 方法的返回...

利用遞迴刪除資料夾(資料夾中套資料夾)

刪除目錄 bool deldir const ansistring p if p.isempty p.length 4 return false 引數必須大於3,即不能為磁碟根目錄或空白 int len p.length char path p.c str ansistring dir ansist...

拷貝檔案 資料夾 建立資料夾 刪除資料夾操作

qt拷貝檔案 資料夾 建立資料夾 刪除資料夾操作 cpp view plain copy brief 拷貝檔案到目的資料夾 param srcfilename 原始檔全路徑,比如 f tx wwxx.txt f tx des desd param desfilepathname 要copy到的目的路...