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

如何使用 FtpWebRequest (.NET) 更改目錄?

How do you change directories using FtpWebRequest (.NET)?(如何使用 FtpWebRequest (.NET) 更改目錄?)
本文介紹了如何使用 FtpWebRequest (.NET) 更改目錄?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

誰能告訴我如何使用 FtpWebRequest 更改目錄?這似乎應該是一件容易的事,但我沒有看到它.

編輯

我只是想補充一下...我對 FtpWebRequest 沒有興趣.如果有更好(更簡單)的方式在 .NET 中執行 FTP,請告訴我.

<小時>

顯然沒有辦法使用實時連接來做到這一點,您需要更改 uri 以欺騙 ftpwebrequest 使用不同的請求(感謝 Jon).

所以我正在尋找第 3 方客戶...

我嘗試過的一些開源解決方案效果不佳(一直崩潰),但我找到了一個通過我的一些初步測試的開源解決方案(.NET FTP 客戶端).

解決方案

有一個博文,它展示了如何偽造它 - 基本上你必須將目錄放在 URL 上.

我懷疑使用專用的 FTP 庫可能會更好 - 一個不會試圖將所有內容都強制轉換為 WebRequest 做事方式的庫.我個人沒有為此使用任何 3rd 方庫,而是搜索FTP library .NET".找到很多候選人.


jcolebrand(以防 2006 年博客 linkrot 的可能性)

<塊引用>

許多客戶詢問我們如何將 CWD 命令與我們的 FtpWebRequest 一起使用.

答案是:不能直接使用命令,但是可以修改uri參數達到同樣的效果.

假設您使用以下格式:

String uri = "ftp://myFtpUserName:myFtpUserPassword@myFtpUrl";FtpWebRequest 請求 = (FtpWebRequest)WebRequest.Create(uri);Request.Method =列表";

<塊引用>

以上示例將帶您進入用戶目錄并列出其中的所有內容.現在假設您要向后移動 2 個目錄并列出其中的內容(前提是您的用戶有權執行此操作).你關閉之前的 FtpWebRequest 并使用這個 uri 發出一個新的

uri = "ftp://myFtpUserName:myFtpUserPassword@myFtpUrl/%2E%2E/%2E%2E";

<塊引用>

這相當于使用您的用戶憑據登錄,然后使用 cd ../../

注意:如果您嘗試直接使用 ".." 而不轉義它們,則 uri 類將刪除它們,因此 "ftp://myFtpUserName:myFtpUserPassword@myFtpUrl/../.." 等價于 "ftp://myFtpUserName:myFtpUserPassword@myFtpUrl/"

現在假設您要轉到另一個用戶的目錄,該目錄比根目錄高一級.如果您不指定用戶名和密碼,則相當于以匿名用戶身份登錄.然后你發出一個新的 FtpWebRequest 和下面的 uri

ftp://myFtpUrl/%2F/anotherUserDir"

<塊引用>

這相當于匿名登錄然后做

Cd/cd 另一個用戶目錄

Can someone tell me how to change directories using FtpWebRequest? This seems like it should be an easy thing to do, but I'm not seeing it.

EDIT

I just want to add...I don't have my heart set on FtpWebRequest. If there's a better (easier) way to do FTP in .NET please let me know.


Apparently there's no way to do it using a live connection, you need to change the uri to trick ftpwebrequest into using a different request (thanks Jon).

So I'm looking for a 3rd party client...

Some of the open source solutions I tried didn't work too well (kept crashing), but I found one open source solution that's passed some of my preliminary tests (.NET FTP Client).

解決方案

There's a blog post from Mariya Atanasova which shows how you can fake it - basically you have to put the directory on the URL.

I suspect you may be better off with a dedicated FTP library though - one that doesn't try to force everything into the WebRequest way of doing things. I haven't personally used any 3rd party libraries for this, but a search for "FTP library .NET" finds lots of candidates.


Edit: jcolebrand (in case of 2006 blog linkrot possibility)

Many customers ask us how they can use the CWD command with our FtpWebRequest.

The answer is: you cannot use the command directly, but you can modify the uri parameter to achieve the same result.

Let's say you're using the following format:

String uri = "ftp://myFtpUserName:myFtpUserPassword@myFtpUrl";
FtpWebRequest Request = (FtpWebRequest)WebRequest.Create(uri);
Request.Method = "LIST";

The above example will bring you to your user's directory and list all the contents there. Now let's say you want to go 2 directories backwards and list the contents there (provided your user has permissions to do that). You close the previous FtpWebRequest and issue a new one with this uri

uri = "ftp://myFtpUserName:myFtpUserPassword@myFtpUrl/%2E%2E/%2E%2E";

This is equivalent to logging in with your user's credentials and then using cd ../../

Note: if you try using the ".." directly without escaping them the uri class will strip them, so "ftp://myFtpUserName:myFtpUserPassword@myFtpUrl/../.." is equivalent to "ftp://myFtpUserName:myFtpUserPassword@myFtpUrl/"

Now let's say you want to go to another user's directory which is one level above the root. If you don't specify a user name and password it's equivalent to logging in as anonymous user. Then you issue a new FtpWebRequest with the following uri

"ftp://myFtpUrl/%2F/anotherUserDir"

This is equivalent to logging in as anonymous and then doing

Cd /
cd anotherUserDirectory

這篇關于如何使用 FtpWebRequest (.NET) 更改目錄?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
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屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 欧洲精品视频一区 | 欧美成人精品二区三区99精品 | 国产你懂的在线观看 | 成人三级电影 | 亚洲成人国产 | 网址黄| 欧美色性 | 国产精品久久久久久久久久久久 | 国产精品成人一区二区三区夜夜夜 | 精品欧美一区二区中文字幕视频 | 91精品国产综合久久久亚洲 | 久久久久综合 | 黄色成人亚洲 | 男人的天堂久久 | 日韩在线| 国产99久久精品一区二区永久免费 | 日韩欧美一区二区三区免费观看 | 日韩免费av| 中文字幕第九页 | 国产一区二区激情视频 | 视频在线h | 成人av播放 | 国产综合久久久久久鬼色 | 欧美精品福利 | 91.com在线观看 | 九九热精品在线 | 黑人巨大精品欧美一区二区免费 | 日本字幕在线观看 | 亚洲不卡在线观看 | 伊色综合久久之综合久久 | 天堂va在线 | www.夜夜草 | 日本成人一区二区 | 国产91在线视频 | 欧美影院 | 欧美激情一区二区三区 | 欧美一级高潮片免费的 | 色av一区 | 久久伊人一区 | 中文字幕黄色大片 | 视频羞羞|