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

如何使用 C# 將多個文件從 FTP 服務器傳輸到本地

How to transfer multiple files from FTP server to local directory using C#?(如何使用 C# 將多個文件從 FTP 服務器傳輸到本地目錄?)
本文介紹了如何使用 C# 將多個文件從 FTP 服務器傳輸到本地目錄?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我可以將一個文件從 ftp 服務器傳輸到本地目錄.使用以下代碼

I can transfer one file from ftp server to local directory. using the following code

  using (WebClient ftpClient = new WebClient())
        {
            ftpClient.Credentials = new System.Net.NetworkCredential("username", "password");
            ftpClient.DownloadFile("ftp://website.com/abcd.docx", @"D:\WestHam	est.docx");

但我不知道如何傳輸多個文件.任何人都可以幫我解決這個問題.}

but i don't know how to transfer multiple files. can anybody help me on this. }

推薦答案

使用此代碼,只需替換用戶憑據:

Use this code, just replace the user credentials:

static void Main(string[] args)
{
    FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create("ftp://mywebsite.com/");
    ftpRequest.Credentials = new NetworkCredential("user345", "pass234");
    ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
    FtpWebResponse response = (FtpWebResponse)ftpRequest.GetResponse();
    StreamReader streamReader = new StreamReader(response.GetResponseStream());           
    List<string> directories = new List<string>();            

    string line = streamReader.ReadLine();
    while (!string.IsNullOrEmpty(line))
    {
        directories.Add(line);
        line = streamReader.ReadLine();
    }
    streamReader.Close();


    using (WebClient ftpClient = new WebClient())
    {
        ftpClient.Credentials = new System.Net.NetworkCredential("user345", "pass234");

        for (int i = 0; i <= directories.Count-1; i++)
        {
            if (directories[i].Contains("."))
            {

                string path = "ftp://mywebsite.com/" + directories[i].ToString();
                string trnsfrpth = @"D:\Test" + directories[i].ToString();
                ftpClient.DownloadFile(path, trnsfrpth);
            }
        }
    }

這篇關于如何使用 C# 將多個文件從 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 令牌授權不起作用)
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屋-程序員軟件開發技
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
Getting access token using email address and app password from oauth2/token(使用電子郵件地址和應用程序密碼從 oauth2/token 獲取訪問令牌)
New Azure AD application doesn#39;t work until updated through management portal(新的 Azure AD 應用程序在通過管理門戶更新之前無法運行)
主站蜘蛛池模板: 国产成人a亚洲精品 | 国产中文字幕在线 | 国产乱码精品一品二品 | 国产高清在线 | 欧美一级一区 | 亚洲欧美成人影院 | 99久久国产综合精品麻豆 | 欧美大片一区二区 | 国产免费一二三区 | 91精品国产综合久久精品图片 | 欧美色图另类 | 91视频在线| 91精品久久 | 久久国产精品色av免费观看 | 粉嫩国产精品一区二区在线观看 | 国产91久久精品一区二区 | 四虎午夜剧场 | 免费黄色的视频 | 欧美一区二区在线播放 | 亚洲精品一区二区三区中文字幕 | 亚洲中午字幕 | 久热国产在线 | 日韩视频免费在线 | 俺去俺来也www色官网cms | 久久久久久91 | 日韩精品一区二区三区 | www.伊人.com | 秋霞a级毛片在线看 | 日日骚av| 天天射色综合 | 在线视频一区二区 | 国产成人一区二区三区 | 性色的免费视频 | 中文字幕一区二区三区四区五区 | 中文字幕一区二区三区在线观看 | 精品一区二区久久久久久久网精 | 久久综合久久久 | 51ⅴ精品国产91久久久久久 | 午夜免费福利电影 | 999久久久 | 欧美日韩a |