unity服务器文件传输,Unity 3D简单C#文件发送到FPT服务器示例脚本?
即使你這樣做,你也會收到錯誤消息:The format of the URI could not be determined: blah blah blah
你的"ftp.byethost7.com";鏈接應該是"ftp://byethost7.com";
這是FTPUnity中的完整上傳代碼。using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.IO;
public class Uploader : MonoBehaviour
{
public string FTPHost = "ftp://byethost7.com";
public string FTPUserName = "b7_18750253";
public string FTPPassword = "xxx";
public string FilePath;
public void UploadFile()
{
FilePath = Application.dataPath + "/StreamingAssets/data.xml";
Debug.Log("Path: " + FilePath);
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);
}
void OnFileUploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
{
Debug.Log("Uploading Progreess: " + e.ProgressPercentage);
}
void OnFileUploadCompleted(object sender, UploadFileCompletedEventArgs e)
{
Debug.Log("File Uploaded");
}
void Start()
{
UploadFile();
}
}
《新程序員》:云原生和全面數(shù)字化實踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的unity服务器文件传输,Unity 3D简单C#文件发送到FPT服务器示例脚本?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 国家服务器1eb硬盘,仅一个月:奇亚币已
- 下一篇: 10月25日lol服务器维护,《LOL》