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

想使用 C# (FtpWebResponse) 從 FTP 讀取文件列表,但它

Want to use C# (FtpWebResponse) to read file list from FTP, but it returns HTML(想使用 C# (FtpWebResponse) 從 FTP 讀取文件列表,但它返回 HTML)
本文介紹了想使用 C# (FtpWebResponse) 從 FTP 讀取文件列表,但它返回 HTML的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時(shí)送ChatGPT賬號..

我使用以下代碼從 FTP 站點(diǎn)獲取文件.它可以在我的計(jì)算機(jī)上運(yùn)行,??但是當(dāng)我在另一臺計(jì)算機(jī)上運(yùn)行它時(shí)它只會(huì)返回 HTML 代碼(當(dāng)我通過瀏覽器訪問 FTP 時(shí),我可以看到 HTML 是網(wǎng)頁的代碼).怎么了?

I use below codes to get files from a FTP site. It works in my computer, but it only return HTML codes when I run it on another computer (I can see that the HTML are codes of web page when I access FTP via browser). What's wrong?

public String GetFilesAsString(string folder,string fileExtension)
{
    StringBuilder result = new StringBuilder();
    FtpWebRequest reqFTP;
    try
    {
        String ftpserver = ftp + folder+"/";

        reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpserver));
        reqFTP.UsePassive = false;
        reqFTP.UseBinary = true;
        reqFTP.Credentials = new NetworkCredential(username, password);
        reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
        FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();

        StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
        string line = "";

        while (reader.Peek()>-1)
        {
            line = reader.ReadLine();
            Console.WriteLine(line);//**********HTML was wrote out here*************
        }

        if (result.ToString().LastIndexOf('
') >= 0)
            result.Remove(result.ToString().LastIndexOf('
'), 1);
        reader.Close();
        response.Close();

        return result.ToString();
    }
    catch (Exception ex)
    {
    }
    return null;
}

推薦答案

會(huì)不會(huì)是網(wǎng)絡(luò)代理干擾?嘗試使用以下方法繞過代理:

Could it be a web proxy interfering? Try to get around the proxy by using the following:

reqFTP.Proxy = GlobalProxySelection.GetEmptyWebProxy();

這篇關(guān)于想使用 C# (FtpWebResponse) 從 FTP 讀取文件列表,但它返回 HTML的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)行)
主站蜘蛛池模板: 亚洲成年影院 | 日韩成人在线一区 | 国产激情一区二区三区 | 亚洲精品456 | 91爱爱·com | 91免费在线看 | 四虎永久免费地址 | 欧美亚洲视频在线观看 | 超碰网址 | 国产精品国产精品国产专区不卡 | 日日干日日操 | 日韩手机在线视频 | 放个毛片看看 | 久久69精品久久久久久国产越南 | 欧美视频三区 | 日韩区| 欧美亚洲国产一区二区三区 | 天堂一区二区三区 | 久久av一区| 在线观看免费高清av | 欧美视频一区二区三区 | 亚洲精品久久久久中文字幕欢迎你 | 日本黄色片免费在线观看 | 九色在线 | 亚洲网站观看 | 蜜桃精品视频在线 | 久久在线| 五月婷婷丁香婷婷 | 国产97在线视频 | 一区二区三区高清在线观看 | 精品国产第一区二区三区 | 人人干97| 看羞羞视频| 特一级毛片 | 国产精品av久久久久久久久久 | 久久久久亚洲av毛片大全 | 亚洲欧美日韩精品久久亚洲区 | 亚洲高清在线 | 二区亚洲| 亚洲精品一区二区三区中文字幕 | 日本成人免费观看 |