UWP - nas network access denied

狂风中的少年 提交于 2020-01-07 04:29:38

问题


I want to read some text files with extensions of .txt, .rtf and .log from a nas in my uwp app.

I have followed the instructions on this link, but there is still a "network access denied" error.

This is my Package.appxmanifest file.

EDIT

  1. I use a FolderPicker to let the user choose the folder containing the log files, then I add that folder to FutureAccessList with a token.
  2. I use the token in 1. to retrieve the folder, then read all the files in it.

Here is the relevant code.

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

Besides, I can get the names of the log files, and when I want to read the contents of them, the error network access denied occurred.

NAS device information: QNAP TS-231P

Any suggestions are welcome, and I can surely provide more details if needed.

Besides, I am looking for a free nas server that I can upload an small sample to test my app, but I fail to find one. I would like to know where I can find it. I am also not sure whether I can ask this on stackoverflow. If it is inappropriate, please direct me where I can post it instead, thanks.

来源:https://stackoverflow.com/questions/46107831/uwp-nas-network-access-denied

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!