久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 WebClient 將文件目錄上傳到 FTP 服務器

Upload directory of files to FTP server using WebClient(使用 WebClient 將文件目錄上傳到 FTP 服務器)
本文介紹了使用 WebClient 將文件目錄上傳到 FTP 服務器的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我已經搜索和搜索,但找不到這樣做的方法.我在要上傳的目錄中有文件.文件名不斷變化,所以我無法按文件名上傳.這是我嘗試過的.

I have searched and searched and cannot find a way to do this. I have files in a directory I want to upload. The file names change constantly so I cannot upload by file name. Here is what I have tried.

using (WebClient client = new WebClient())
{
    client.Credentials = new NetworkCredential("User", "Password");
    foreach (var filePath in files)
        client.UploadFile("ftp://site.net//PICS_CAM1//", "STOR", @"PICS_CAM1");
}

但我得到一個編譯器錯誤:

But I am getting a compiler error:

當前上下文中不存在名稱文件"

The name 'files' does not exist in the current context

我研究過的一切都表明這應該有效.

Everything I have researched says this should work.

有沒有人可以通過 WebClient 上傳文件目錄的好方法?

Does anyone have a good way to upload a directory of files via WebClient?

推薦答案

你必須定義和設置文件.如果您想上傳某個本地目錄中的所有文件,例如使用 Directory.EnumerateFiles.

You have to define and set the files. If you wanted to upload all files in a certain local directory, use for example Directory.EnumerateFiles.

也是 address 參數noreferrer">WebClient.UploadFile 必須是目標文件的完整 URL,而不僅僅是目標目錄的 URL.

Also the address argument of WebClient.UploadFile has to be a full URL to a target file, not just a URL to a target directory.

IEnumerable<string> files = Directory.EnumerateFiles(@"C:localfolder");

using (WebClient client = new WebClient())
{
    client.Credentials = new NetworkCredential("username", "password");

    foreach (string file in files)
    {
        client.UploadFile(
            "ftp://example.com/remote/folder/" + Path.GetFileName(file), file);
    }
}

有關遞歸上傳,請參閱:
C#遞歸上傳到FTP服務器

For a recursive upload, see:
Recursive upload to FTP server in C#

這篇關于使用 WebClient 將文件目錄上傳到 FTP 服務器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 免费v片 | 精品中文字幕一区二区 | 亚洲一区亚洲二区 | 久久国产精品一区二区三区 | 欧美三区在线观看 | 国产一区二区精品在线观看 | 五月天婷婷久久 | 91婷婷韩国欧美一区二区 | 日日草夜夜草 | 日韩在线免费视频 | 91久久北条麻妃一区二区三区 | 在线播放国产一区二区三区 | 国产高清视频一区二区 | 成人在线亚洲 | 中国一级特黄真人毛片 | 在线视频 中文字幕 | 亚洲国产成人精品女人久久久 | 亚洲乱码一区二区三区在线观看 | 久亚州在线播放 | 久久久国产精品视频 | 欧美一级二级在线观看 | 欧美日韩精品久久久免费观看 | 国产精品第2页 | 欧美日韩视频在线第一区 | 国产精品久久久久久网站 | 久久久久久久国产精品视频 | www.性色 | 网站国产| 免费国产视频在线观看 | 视频一区二区三区四区五区 | 中文字幕一区在线观看视频 | 一级在线观看 | 成人国产精品一级毛片视频毛片 | www.日日干| 四虎影院欧美 | 爱爱视频在线观看 | 国产精品美女久久久久久久久久久 | 97成人免费| 欧美黑人体内she精在线观看 | 成人在线免费观看视频 | 亚洲综合一区二区三区 |