Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 通过C在ftp上上载文件或创建名称中包含unicode字符的目录#_C#_Unity3d_Unicode_Ftp - Fatal编程技术网

C# 通过C在ftp上上载文件或创建名称中包含unicode字符的目录#

C# 通过C在ftp上上载文件或创建名称中包含unicode字符的目录#,c#,unity3d,unicode,ftp,C#,Unity3d,Unicode,Ftp,我需要通过C#(在Unity engine中)在ftp上创建文件或目录。我尝试通过以下方式上载文件: public void upload(string remoteFile, string file_content) { try { string address = host + @"/текст.txt"; Debug.Log(address); // gives a normal address in Unicode ftpR

我需要通过C#(在Unity engine中)在ftp上创建文件或目录。我尝试通过以下方式上载文件:

public void upload(string remoteFile, string file_content)
{
    try
    {
        string address = host + @"/текст.txt";
        Debug.Log(address); // gives a normal address in Unicode
        ftpRequest = (FtpWebRequest)FtpWebRequest.Create(address);
        ftpRequest.Credentials = new NetworkCredential(user, pass);
        ftpRequest.UseBinary = true;
        ftpRequest.UsePassive = true;
        ftpRequest.KeepAlive = true;
        ftpRequest.ContentLength = file_content.Length;
        ftpRequest.Method = WebRequestMethods.Ftp.UploadFile;
        byte[] byteBuffer = System.Text.Encoding.Unicode.GetBytes(file_content);
        try
        {
            using (ftpStream = ftpRequest.GetRequestStream())
            {
                ftpStream.Write(byteBuffer, 0, byteBuffer.Length);
                Debug.Log(Convert.ToString(byteBuffer));
            }
        }
        catch (Exception ex) 
        { 
            ErrorScene.error = "Local Error: 1. " + ex.ToString(); SceneManager.LoadScene("ErrorScene", LoadSceneMode.Single); 
        }
        ftpStream.Close();
        ftpRequest = null;
    }
    catch (Exception ex) 
    { 
        ErrorScene.error = "Local Error: 2. " + ex.ToString(); SceneManager.LoadScene("ErrorScene", LoadSceneMode.Single); 
    }
    return;
}
在ftp中调用此函数后,将创建一个名为?????.txt的文件

与目录类似

有办法做到这一点吗


提前感谢。

您可以使用任何独立的FTP客户端在服务器上创建这样的文件吗?给我们看看它的日志文件!即使可以,您是否可以上传一个文件,其中包含来自不同字母表的字母(例如日语)?证明Unicode正在被使用。嗨,马丁!是的,我可以手动创建名称中包含unicode字符的目录。我试着用亚美尼亚语创建文件夹,得到了同样的结果。重新记录文件,我找不到,可能是服务器上的登录被禁用了。谢谢您的回答,很抱歉通知晚了。请出示客户日志。还有——对我来说,你的代码很好用,包括西里尔语和亚美尼亚语。