【问题标题】:File not found exception - windows phone找不到文件异常 - windows phone
【发布时间】:2014-04-25 10:24:07
【问题描述】:

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

 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-84DA-C5F8EB50D947}\client_secrets.json'

【问题讨论】:

  • 在黑暗中拍摄,但你可以试试new FileStream("client_secrets.json", ... 因为我试图在同一根目录中的一个类中打开流,它适用于 BuildAction = Content 的简单文件。
  • Romasz 评论应该可以解决您的问题
  • 是的。你想把它作为答案发布,以便我接受吗?

标签: c# exception windows-phone-8 file-io windows-phone


【解决方案1】:

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

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

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);

【讨论】:

  • 我收到此错误找不到文件'C:\Data\Programs\{68788282-E5AD-4D0C-84DA-C5F8EB50D947}\Install\client_secrets.json'
  • 不,我的系统中没有像 C:\Data 这样的路径
  • 你的client_secrets.json在哪里?
  • 在我的项目里面说 myproject/client_secret.json
猜你喜欢
  • 1970-01-01
  • 2013-04-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多