久久久久久久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 超時)
主站蜘蛛池模板: 久久精品亚洲 | 久草青青草 | 久久精品久久久久久 | 国产精品久久久久一区二区 | 国产精品7777777 | 国产精品美女久久久久久不卡 | 精品国产乱码久久久久久蜜退臀 | 丁香婷婷综合激情五月色 | 最新伦理片 | 欧美1区2区 | 午夜精品久久久久久久久久久久久 | 国产日产久久高清欧美一区 | 国产成人精品视频在线观看 | 午夜激情国产 | 国产婷婷精品av在线 | 亚洲精品一区二区冲田杏梨 | 欧美男人天堂 | 日韩欧美一级片 | 亚洲欧美高清 | 精品一区免费 | 91精品久久久久久久 | 啪啪网页 | 精品天堂| 美女日批免费视频 | 日本三级电影在线观看视频 | 人操人免费视频 | 欧美一级淫片007 | 成人免费xxxxx在线视频 | 九九热最新视频 | 一区二区精品 | 久久综合一区二区 | 日韩精品在线播放 | 精品久久久久久久久久久 | 美女久久久久 | 国产乱码精品一区二区三区五月婷 | 精品欧美一区二区在线观看 | 超碰人人在线 | 黄色三级免费网站 | 亚洲一区二区三区在线视频 | 亚洲永久 | 国产99视频精品免视看9 |