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

在 C# 中獲取 FTP 上的文件大小

Get File Size On An FTP in C#(在 C# 中獲取 FTP 上的文件大小)
本文介紹了在 C# 中獲取 FTP 上的文件大小的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我想獲取 FTP 上文件的大小.

I want to get the size of a file on an FTP.

        //Get File Size
        reqSize = (FtpWebRequest)FtpWebRequest.Create(new Uri(FtpPath + filePath));
        reqSize.Credentials = new NetworkCredential(Username, Password);
        reqSize.Method = WebRequestMethods.Ftp.GetFileSize;
        reqSize.UseBinary = true;
        FtpWebResponse respSize = (FtpWebResponse)reqSize.GetResponse();
        long size = respSize.ContentLength;
        respSize.Close();

我嘗試了以下方法,但收到 550 錯誤.找不到文件/無法訪問.但是,以下代碼有效...

I have tried the following but get a 550 error. File not found / no access. However, the following code works...

                reqTime = (FtpWebRequest)FtpWebRequest.Create(new Uri(FtpPath + filePath));
                reqTime.Credentials = new NetworkCredential(Username, Password);
                reqTime.Method = WebRequestMethods.Ftp.GetDateTimestamp;
                reqTime.UseBinary = true;
                FtpWebResponse respTime = (FtpWebResponse)reqTime.GetResponse();
                DateTime LastModified = respTime.LastModified;
                respTime.Close();

這對我不起作用的原因是我的 FTP 服務器不支持 SIZE 方法.

推薦答案

試試reqSize.Method = WebRequestMethods.Ftp.GetFileSize;而不是 GetDateTimestamp

Try reqSize.Method = WebRequestMethods.Ftp.GetFileSize; instead of GetDateTimestamp

這對我有用:

FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://servername/filepath"));
request.Proxy = null;
request.Credentials = new NetworkCredential("user", "password");
request.Method = WebRequestMethods.Ftp.GetFileSize;

FtpWebResponse response = (FtpWebResponse)request.GetResponse();
long size = response.ContentLength;
response.Close();

這篇關于在 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 應用程序在通過管理門戶更新之前無法運行)
主站蜘蛛池模板: 欧美手机在线 | 青青草久久 | 久久亚洲成人 | 国产www视频 | 欧美又大粗又爽又黄大片视频 | 中文字幕高清在线 | 特级黄色大片 | 日韩久久一区 | 亚洲综合一区二区 | 国产精品福利在线观看 | 国产黄色在线观看 | 欧美性色网 | 久久精品伊人 | 国产黄色在线观看 | 精品一区三区 | 成人午夜激情视频 | www.日韩av| 久久a级片 | 色天天综合 | 在线免费毛片 | 青青伊人网 | 色偷偷网站| 成人小视频在线观看 | 日本免费高清 | 国产成年人视频 | 亚洲视频免费观看 | 欧美又大又硬又粗bbbbb | 午夜高清 | 亚洲第一区在线观看 | 亚洲天堂一区二区 | 五月久久| 偷拍一区二区 | 久久午夜精品 | 欧美色偷偷 | 国产精品亚洲综合 | 欧美精品国产 | 伦一理一级一a一片 | 影音先锋中文字幕在线 | 日本中文字幕在线播放 | 久久午夜精品 | 97福利视频 |