相关疑难解决方法(0)

无法将“System.Net.FileWebRequest”类型的对象转换为“System.Net.HttpWebRequest”类型

我在尝试上传到 FTP 时遇到上述错误。但是当我尝试从本地计算机运行此代码时,它出现错误。好心提醒。

这是我的代码如下:

 static void Main(string[] args)
    {

        var yourListOfFilePaths = Directory.GetFiles(filepath);

        using (ZipFile zip = new ZipFile())
        {
            foreach (string filePath in yourListOfFilePaths)
            {
                zip.AddFile(filePath);    // FILE PATH LOCATION / WHICH FOLDER FILES YOU WANTED TO ZIP
                zip.Password = "abc1234"; // CHANGE YOUR PASSWORD HERE 
            }
            zip.Save(ZipPath + "\\Batch_" + DateTime.Now.ToString("ddMMyy") + ".zip");

            FtpWebRequest request = (FtpWebRequest)WebRequest.Create("http://www.bitrix24.com/" + "\\Batch_" + DateTime.Now.ToString("ddMMyy") + ".zip");
            request.Method = WebRequestMethods.Ftp.UploadFile;
            // This example assumes the FTP site uses anonymous logon.
            request.Credentials = …
Run Code Online (Sandbox Code Playgroud)

.net c# c#-3.0 c#-4.0

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

.net ×1

c# ×1

c#-3.0 ×1

c#-4.0 ×1