C# 上载带有特殊unicode字符的文件时出现Google驱动器解析错误

C# 上载带有特殊unicode字符的文件时出现Google驱动器解析错误,c#,google-api,google-drive-api,google-api-dotnet-client,C#,Google Api,Google Drive Api,Google Api Dotnet Client,最近,在尝试使用Google API dotnet客户端sdk上载文件时出现了一个问题。当文件名包含任何特殊的Unicode字符时,将抛出一个错误 这是我的密码 public static Google.Apis.Drive.v2.Data.File InsertResource(Google.Apis.Drive.v2.DriveService service, string filePath, string parentId, string fileName, string mime

最近,在尝试使用Google API dotnet客户端sdk上载文件时出现了一个问题。当文件名包含任何特殊的Unicode字符时,将抛出一个错误

这是我的密码

    public static Google.Apis.Drive.v2.Data.File InsertResource(Google.Apis.Drive.v2.DriveService service, string filePath, string parentId, string fileName, string mimeType)
    {
        Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();

        try
        {
            // File's metadata.

            body.Title = fileName;
            body.MimeType = mimeType;

            // Set the parent folder.
            if (!String.IsNullOrEmpty(parentId))
            {
                var response = DriveUtils.GetFileInfo(service, parentId);
                if (response.Error != null)
                {
                    body.Error = response.Error;
                    return body;
                }
                body.Parents = new List<ParentReference>() { new ParentReference() { Id = parentId } };
            }

            byte[] byteArray = System.IO.File.ReadAllBytes(filePath);
            MemoryStream stream = new MemoryStream(byteArray);

            Google.Apis.Drive.v2.FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, mimeType);

            request.Upload();
            return request.ResponseBody;

        }
        catch (GoogleApiRequestException e)
        {
            body.Error = e.RequestError;
            return body;
        }
}
public static Google.api.Drive.v2.Data.File InsertResource(Google.api.Drive.v2.DriveService服务、字符串文件路径、字符串parentId、字符串文件名、字符串mimeType)
{
Google.api.Drive.v2.Data.File body=新的Google.api.Drive.v2.Data.File();
尝试
{
//文件的元数据。
body.Title=文件名;
body.MimeType=MimeType;
//设置父文件夹。
如果(!String.IsNullOrEmpty(parentId))
{
var response=DriveUtils.GetFileInfo(服务,父ID);
if(response.Error!=null)
{
body.Error=response.Error;
返回体;
}
body.Parents=new List(){new ParentReference(){Id=parentId}};
}
byte[]byteArray=System.IO.File.ReadAllBytes(文件路径);
MemoryStream stream=新的MemoryStream(byteArray);
Google.api.Drive.v2.filesrource.InsertMediaUpload请求=service.Files.Insert(body、stream、mimeType);
request.Upload();
返回request.ResponseBody;
}
捕获(GoogleApiRequestException e)
{
body.Error=e.RequestError;
返回体;
}
}
到本周为止,一切都很顺利。名称中包含汉字或土耳其语字符的任何文件都将抛出错误

位于Google.api.Json.JsonReader.ParseExpression(JsonToken令牌,令牌流) 在Google.api.Json.JsonReader.Parse(字符串jsonAsText)
在Google.API.Upload.ResumableUpload`1.Upload()

尝试下载最新版本的API(从)。 我将(下载此示例的说明)更改为
标题=”字/漢字" 和Title=“Title withç”,这两种方法对我都有效。

我遇到了同样的问题,但我直接使用webRequest,所以我只在json对象击中google drive服务器时才会出错: