相关疑难解决方法(0)

使用FtpWebRequest输出日志

我想知道是否可以使用我的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)

c# ftp logging ftpwebrequest

7
推荐指数
2
解决办法
5553
查看次数

FtpWebRequest 在使用正确密码成功连接后忽略错误密码

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)

.net c# ftp webrequest ftpwebrequest

5
推荐指数
1
解决办法
467
查看次数

标签 统计

c# ×2

ftp ×2

ftpwebrequest ×2

.net ×1

logging ×1

webrequest ×1