久久久久久久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的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

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

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

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ò)代理干擾?嘗試使用以下方法繞過(guò)代理:

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的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(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)證并跨請(qǐng)求保留自定義聲明)
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 訪問(wèn)令牌和刷新令牌) - IT屋-程序員軟件開(kāi)發(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 獲取訪問(wèn)令牌)
New Azure AD application doesn#39;t work until updated through management portal(新的 Azure AD 應(yīng)用程序在通過(guò)管理門戶更新之前無(wú)法運(yùn)行)
主站蜘蛛池模板: 久久av综合| 美日韩一区二区 | 国产精品久久久久久婷婷天堂 | 91精品国产高清一区二区三区 | 黄色毛片免费 | av天天干 | 福利视频网 | 亚洲精品视频三区 | 日本精品视频一区二区三区四区 | 免费大黄视频 | 在线观看中文字幕亚洲 | 日韩精品视频一区二区三区 | 成人免费视频观看视频 | 国产精品福利视频 | 日韩中文字幕区 | 国产精品视频久久久久久 | 久久专区| 一级黄色片网址 | 91视频免费黄 | 国产精品久久久久久久久久 | 天天综合久久 | 91观看 | 国产成人99久久亚洲综合精品 | 国产精品国产三级国产aⅴ无密码 | 黄色一级免费 | 一级少妇女片 | 国产一区二区三区四 | 综合激情av| 三级av在线| 国产在线不卡视频 | 久久久精品视频一区二区三区 | 国产高清精品一区二区三区 | 91文字幕巨乱亚洲香蕉 | 午夜久久av | 成人h动漫亚洲一区二区 | 亚洲一二三在线 | 夜夜骑首页| 久久久xxx| 夜夜夜夜夜夜曰天天天 | 欧美成人a| 国产不卡视频 |