UWP - nas网络访问被拒绝

时间:2017-09-08 02:41:23

标签: uwp nas

我想在我的uwp应用程序中从nas读取一些扩展名为.txt,.rtf和.log的文本文件。

我已遵循此link上的说明,但仍有“网络访问被拒绝”错误。

这是我的Package.appxmanifest文件。

Package.appxmanifest

修改

  1. 我使用FolderPicker让用户选择包含日志文件的文件夹,然后使用令牌将该文件夹添加到FutureAccessList
  2. 我使用1.中的令牌来检索文件夹,然后读取其中的所有文件。
  3. 以下是相关代码。

    1. public async static void locateLogsFolder()
      {
          var folderPicker = new FolderPicker();
          folderPicker.FileTypeFilter.Add("*");
          folderPicker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
      
          IStorageFolder folder = await folderPicker.PickSingleFolderAsync();
          if (folder != null)
          {
              // Add to MRU with metadata (For example, a string that represents the date)
              string mruToken = StorageApplicationPermissions.MostRecentlyUsedList.Add(folder);
      
              // Add to FA without metadata
              string faToken = StorageApplicationPermissions.FutureAccessList.Add(folder);
      
              // To open this worksheet file later
              ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
              localSettings.Values[logsFolderKey] = faToken;
      
              loadData();
          }
          else
          {
              // The file picker was dismissed with no file selected to save
          }
      }
      

      2

      private static async Task<bool> loadLogFiles()
      {
          ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
          if (localSettings.Values.ContainsKey(logsFolderKey))
          {
              string logsFolderPath = localSettings.Values[logsFolderKey].ToString();
              IStorageFolder logsFolder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(logsFolderPath);
              logFiles = await logsFolder.GetFilesAsync();
              return true;
          }
          else
          {
              string message = "Logs folder has not been loaded successfully. \n"
                             + "Please locate the logs folder via the button on the upper left corner.";
              Utils.showMessage(message);
              return false;
          }
      }
      
    2. 此外,我可以获取日志文件的名称,当我想读取它们的内容时,发生错误network access denied

      NAS设备信息:QNAP TS-231P

      欢迎提出任何建议,如果需要,我当然可以提供更多详细信息。

      此外,我正在寻找一个免费的nas服务器,我可以上传一个小样本来测试我的应用程序,但我找不到。我想知道我在哪里可以找到它。我也不确定我是否可以在stackoverflow上问这个问题。如果不合适,请指示我发布的地方,谢谢。

0 个答案:

没有答案