我想知道是否可以使用我的FTP客户端输出日志FtpWebRequest.
像这样的东西:
[R] USER xxx
[R] 331 Please specify the password.
[R] PASS (hidden)
[R] 230 Login successful.
[R] SYST
[R] 215 UNIX Type: L8
[R] FEAT
[R] 211-Features:
[R] EPRT
[R] EPSV
[R] MDTM
[R] PASV
[R] REST STREAM
[R] SIZE
[R] TVFS
[R] 211 End
[R] PWD
[R] 257 "/"
[R] CWD /
[R] 250 Directory successfully changed.
[R] PWD
[R] 257 "/"
[R] TYPE A
[R] 200 Switching to ASCII mode.
[R] PASV
[R] 227 …Run Code Online (Sandbox Code Playgroud) FtpWebRequest在 C# 中使用类时遇到问题。
当我第一次尝试使用正确的凭据将文件上传到 FTP 服务器,然后第二次使用错误的凭据(用户名相同但密码错误)时,没有抛出异常,文件仍然上传到 FTP服务器。请考虑以下代码:
using System;
using System.Net;
internal class Program
{
private static void Main(string[] args)
{
var uri = new Uri("ftp://ftp.dlptest.com/TestFile.txt");
var method = WebRequestMethods.Ftp.UploadFile;
//Here I'm uploading the test file using correct credentials
var correctCredentials =
new NetworkCredential("dlpuser@dlptest.com", "fwRhzAnR1vgig8s");
DoFtpRequest(uri, correctCredentials, method);
//Here I'm uploading the test file using wrong credentials.
//I expect some exception to be thrown and the file not being
//uploaded to the server, neither is the case.
var wrongCredentials …Run Code Online (Sandbox Code Playgroud)