第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

為什么在C#中上傳文件到FTP服務(wù)器要給文件添加頁眉和頁腳

為什么在C#中上傳文件到FTP服務(wù)器要給文件添加頁眉和頁腳

C#
縹緲止盈 2021-11-21 14:59:40
我正在嘗試使用 C# 將文件上傳到 FTP 服務(wù)器。除了我的所有文件(一旦在服務(wù)器上)都有頁眉和頁腳這一事實(shí)之外,上傳工作正常。這里有一個(gè)例子:--------------8d5fde16cb03f95Content-Disposition: form-data; name="file"; filename="PNPP190618.manifest"Content-Type: application/octet-stream<Real file content here>--------------8d5fde16cb03f95當(dāng)然我檢查了我的原始文件沒有這個(gè)文本,我上傳了一些有同樣問題的二進(jìn)制文件。謝謝你。編輯:忘記向您展示我的代碼:        WebClient client = new System.Net.WebClient();        Uri uri = new Uri(FTPHost + new FileInfo(FilePath).Name);        client.UploadProgressChanged += new UploadProgressChangedEventHandler(OnFileUploadProgressChanged);        client.UploadFileCompleted += new UploadFileCompletedEventHandler(OnFileUploadCompleted);        client.Credentials = new System.Net.NetworkCredential(FTPUserName, FTPPassword);        client.UploadFileAsync(uri, "STOR", FilePath);EDIT2:WinSCP 會(huì)話日志(此方法沒有問題):https : //pastebin.com/sv7FNC0iEDIT3:我沒有使用代理。我試圖在 Unity 2017 (Mono .NET 3.5) 和控制臺(tái)項(xiàng)目 (.NET Framework 3.5) 的最小示例上重現(xiàn)該問題。.NET Framework 沒有問題,但在 Unity 2017 中有問題。以下是重現(xiàn)最小 Unity 項(xiàng)目的步驟:創(chuàng)建一個(gè)新的空白 Unity 項(xiàng)目在場(chǎng)景中添加一個(gè)空的 GameObject,并添加一個(gè)新腳本粘貼下面的代碼并將類名替換為您的腳本文件名用文件和FTP服務(wù)器的示例填充屬性按播放using System;using System.IO;using System.Net;using UnityEngine;public class Test : MonoBehaviour {    string FTPHost = "ftp://Fill here";    string FTPUserName = "Fill here";    string FTPPassword = "Fill here";    string FilePath = "Fill here";    // Use this for initialization    void Start () {        WebClient client = new WebClient();        Uri uri = new Uri(FTPHost + new FileInfo(FilePath).Name);        client.Credentials = new NetworkCredential(FTPUserName, FTPPassword);        client.UploadFile(uri, WebRequestMethods.Ftp.UploadFile, FilePath);    }    // Update is called once per frame    void Update () {    }}
查看完整描述

1 回答

?
拉莫斯之舞

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超10個(gè)贊

我改用了 FtpWebRequest。代碼要復(fù)雜得多,但它有效:


    FtpState state = new FtpState();

    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(uri);

    request.Method = WebRequestMethods.Ftp.UploadFile;


    request.Credentials = new NetworkCredential (FTPUserName,FTPPassword);


    state.Request = request;

    state.FileName = FilePath;


    request.BeginGetRequestStream(

        new AsyncCallback (EndGetStreamCallback), 

        state

    );

從 MSDN 文檔中復(fù)制并粘貼 EndGetStreamCallback 和 FtpState。


查看完整回答
反對(duì) 回復(fù) 2021-11-21
  • 1 回答
  • 0 關(guān)注
  • 201 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)