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

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

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

問題描述

限時送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 服務(wù)器不支持 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();

這篇關(guān)于在 C# 中獲取 FTP 上的文件大小的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
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)行)
主站蜘蛛池模板: 香蕉久久网 | 操操网站 | 国产一区不卡在线观看 | 亚洲毛片一区二区 | 国产精品久久久久aaaa九色 | 久热国产精品视频 | 亚洲美女在线视频 | 国产一级片一区二区 | 国产精品永久免费 | 国产成人久久久 | 天天干夜夜拍 | 毛片免费视频 | 日韩中文字幕 | 91福利电影在线观看 | 国产高清视频一区 | 伊人久久成人 | 久草在线免费资源 | 国产小视频精品 | 午夜播放器在线观看 | 51ⅴ精品国产91久久久久久 | 超碰日本 | 午夜成人在线视频 | 91精品国产91 | 九色一区| 欧洲国产精品视频 | 四虎精品在线 | 国产91一区二区三区 | 欧美一区二区三区四区在线 | 国产精品视频网站 | 国产视频在线观看一区二区三区 | 91精品国产91久久综合桃花 | 午夜精品久久久久99蜜 | 日本天天操| 欧美成人hd | 在线播放第一页 | 欧美精品网 | 久久精品国产一区二区 | 91视频在线网站 | 福利成人 | 亚洲日本中文字幕在线 | 五月激情综合 |