找不到windows phone的文件

本文关键字:文件 phone windows 找不到 | 更新日期: 2023-09-27 17:59:58

我正在尝试将Google oAuth 2.0集成到我的windows手机应用程序中。我的项目根目录中的client_secret.json文件及其构建操作被设置为content。这是我的代码

 var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                   new FileStream("../client_secrets.json", FileMode.Open, FileAccess.Read),
                   new[] { DriveService.Scope.Drive },
                   "user",
                   CancellationToken.None);

我得到以下错误

System.IO.FileNotFoundException:找不到文件"C:''Data''Programs{68788282-E5AD-4D0C-84DAC5F8EB5D947}''client_secrets.json"

找不到windows phone的文件

我认为你的道路在某种程度上被打破了?

这是一个疯狂的猜测,但当你尝试这个时,它能解决吗?

string yourpath = Environment.CurrentDirectory + @"'client_secrets.json";
var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                   new FileStream(yourpath, FileMode.Open, FileAccess.Read),
                   new[] { DriveService.Scope.Drive },
                   "user",
                   CancellationToken.None);