# 工作筆記 #8 - FileZilla Server 設定與壓縮檔上傳 需求 --- > 測試上傳壓縮檔至本地 FTP Server <br /> 前置作業 --- ### 1. 安裝 [FileZilla](https://filezilla-project.org/) Server ![](https://i.imgur.com/pWa0NaG.png) <br /> ##### * 安裝時設置密碼。 ![](https://i.imgur.com/bu2lCai.png) <br /> ### 2. 安裝 [FileZilla](https://filezilla-project.org/) Client ![](https://i.imgur.com/waXxEbM.png) <br /> ### 3. 開啟 FileZilla Server。 > 路徑:C:\Program Files\FileZilla Server\filezilla-server-gui.exe ##### * 填入安裝時設定的密碼。 ![](https://i.imgur.com/WZLJgbe.png) ##### * 設定使用者。 ![](https://i.imgur.com/PEs7z0R.png) ![](https://i.imgur.com/gNFf7eB.png) <br /> ### 4. 測試連線。 ##### * 開啟 FileZilla Client。(路徑:C:\Program Files\FileZilla FTP Client\filezilla.exe) ![](https://i.imgur.com/cbQSJhX.png) ##### * 新增站台 ![](https://i.imgur.com/7cM6uNf.png) <br /> 程式說明 --- > 上傳檔案至 FTP Server ``` public bool UploadFile() { try { string ftpPath = "ftp://" + "ip(127.0.0.1)" + "/上傳路徑/" + "檔案名稱"; // 要上傳的檔案 StreamReader sourceStream = new StreamReader("檔案路徑"); byte[] data; using (MemoryStream ms = new MemoryStream()) { sourceStream.BaseStream.CopyTo(ms); data = ms.ToArray(); } sourceStream.Close(); WebClient wc = new WebClient(); wc.Credentials = new NetworkCredential("使用者名稱", "密碼"); wc.UploadData(ftpPath, data); return true; } catch (Exception ex) { return false; } } ``` <br /> ###### tags: `FileZilla` `FTP` `.net` --- 參考資料 > https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/740866/