No000083 檔案與資料夾操作

2022-01-21 20:47:00 字數 1432 閱讀 3840

#region folder option 資料夾操作

//////指定目錄是否存在

/// ///

資料夾路徑

///public

static

bool direxist(string

dirpath)

else

}catch

(exception ex)

}//////

建立目錄

/// ///

public

static

void makedir(string

dirpath)

}catch

(exception ex)

}#endregion folder option 資料夾操作

#region file option 檔案操作

//////指定檔案是否存在

/// ///

///public

static

bool fileexist(string

filepath)

else

}catch

(exception ex)

}//////

讀檔案

/// ///

檔案路徑

///public

static

string readfile(string

filepath)

return

content;

}catch

(exception ex)

}//////

寫檔案

/// ///

檔案路徑

///寫入的內容

public

static

void writefile(string filepath, string

content)

filestream filestream = new filestream(filepath, filemode.openorcreate, fileaccess.readwrite, fileshare.readwrite); //

建立寫入檔案

streamwriter sw = new

streamwriter(filestream, encoding.utf8);

sw.writeline(content);

//開始寫入值

filestream.flush(); //

確保全部寫入

sw.close();

filestream.close();

}catch

(exception ex)

}#endregion file option 檔案操作

python os shutil 檔案 資料夾操作

python中對檔案 資料夾 檔案操作函式 的操作需要涉及到os模組和shutil模組。得到當前工作目錄,即當前python指令碼工作的目錄路徑 os.getcwd 返回指定目錄下的所有檔案和目錄名 os.listdir 函式用來刪除乙個檔案 os.remove 刪除多個目錄 os.removedi...

4 資料夾及檔案壓縮

呼叫 string sourcepath f zazhi book 2013 09 zipmanager zm new zipmanager sourcepath zm.zipfolder sourcepath zip 寫乙個建構函式,用來接收要執行壓縮的檔案路徑 public zipmanager...

Win7資料夾怎麼加密 win7資料夾加密技巧

相信使用過win7的朋友都會遇上這樣乙個問題 有些情況下,不想讓自己的東西給別人看到,總想讓自己的一些 私隱 給藏起來。那麼win7資料夾怎麼加密呢?下面一起來看看吧。第一步 首先在win7開始選單中,點選開啟 執行 然後輸入 cmd 按回車鍵開啟。第二步 然後是通過命令建立加密資料夾,具體方法是鍵...