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

How to transfer multiple files from FTP server to local directory using C#?(如何使用 C# 將多個(gè)文件從 FTP 服務(wù)器傳輸?shù)奖镜啬夸?)
本文介紹了如何使用 C# 將多個(gè)文件從 FTP 服務(wù)器傳輸?shù)奖镜啬夸?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時(shí)送ChatGPT賬號(hào)..

我可以將一個(gè)文件從 ftp 服務(wù)器傳輸?shù)奖镜啬夸?使用以下代碼

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");

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

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

推薦答案

使用此代碼,只需替換用戶憑據(jù):

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);
            }
        }
    }

這篇關(guān)于如何使用 C# 將多個(gè)文件從 FTP 服務(wù)器傳輸?shù)奖镜啬夸?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進(jìn)行身份驗(yàn)證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權(quán)不起作用)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護(hù)進(jìn)程或服務(wù)器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發(fā)技
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調(diào)用時(shí) Azure KeyVault Active Directory AcquireTokenAsync 超時(shí))
Getting access token using email address and app password from oauth2/token(使用電子郵件地址和應(yīng)用程序密碼從 oauth2/token 獲取訪問令牌)
New Azure AD application doesn#39;t work until updated through management portal(新的 Azure AD 應(yīng)用程序在通過管理門戶更新之前無法運(yùn)行)
主站蜘蛛池模板: 国产视频精品视频 | 夜夜骑首页 | 亚洲激情综合 | 欧美区在线| 国产精品国产精品国产专区不片 | 久久精品a | 欧美国产日本一区 | 午夜大片 | 日韩综合网 | 国产精品日女人 | 美女黄色在线观看 | 日韩美女一区二区三区在线观看 | 国产精品一区久久久 | 国产中文在线观看 | 国产美女自拍视频 | 超碰免费在线 | 一区二区在线观看免费视频 | 国产日韩精品在线 | 国产欧美一区二区三区国产幕精品 | 中文字幕在线一区二区三区 | 日韩欧美在线观看一区 | 欧美二区在线 | 精品国产伦一区二区三区观看说明 | 国产精品久久久久久久久图文区 | 午夜视频一区二区 | 羞羞视频免费在线观看 | 在线视频中文字幕 | 久久久久久色 | 欧美二区在线 | 久久av一区二区三区 | 99精品国产一区二区青青牛奶 | 欧美精品一区二区在线观看 | 成人av电影在线 | 国产精品久久久久久二区 | 男女污污动态图 | 特一级毛片| 91九色在线观看 | 欧美日韩视频在线播放 | 天天躁人人躁人人躁狂躁 | 91在线精品秘密一区二区 | 久久久精品一区 |