-1
我已經構建了一個應用程序,用於讀取配置文件並加載基於xml的字典。 我想要的是不需要將該文件添加到程序中。相反,我希望能夠上傳到pi3,然後告訴程序刷新並閱讀我上傳的文件。它將包含在代碼中的文件加載到一個模糊的文件夾中。
如何將我的代碼中的路徑上載並指定到更容易找到的文件夾中。如何在運行Windows 10的樹莓派上上傳和讀取文件IoT
在此先感謝
我已經構建了一個應用程序,用於讀取配置文件並加載基於xml的字典。 我想要的是不需要將該文件添加到程序中。相反,我希望能夠上傳到pi3,然後告訴程序刷新並閱讀我上傳的文件。它將包含在代碼中的文件加載到一個模糊的文件夾中。
如何將我的代碼中的路徑上載並指定到更容易找到的文件夾中。如何在運行Windows 10的樹莓派上上傳和讀取文件IoT
在此先感謝
使用Windows.Storage命名空間,並按照創建,訪問和其他操作,如在這些文件夾和文件上UWP下面的代碼。
//Get Installation Folder for current application
StorageFolder rootFolder = ApplicationData.Current.LocalFolder;
//Create a folder in the root folder of app if not exist and open if exist.
StorageFolder Folder = await rootFolder.CreateFolderAsync(yourFolderName, CreationCollisionOption.OpenIfExists);
//Craete a file in your folder if not exist and replace it with new file if exist
StorageFile sampleFile = await Folder.CreateFileAsync("samplefile.xml", CreationCollisionOption.ReplaceExisting);
//Create your text and write it on your configuaration file
string yourText = "Your Sample Text or Configuration";
await Windows.Storage.FileIO.WriteTextAsync(sampleFile, yourText);
之後,您可以再次訪問文件,從ReadTextAsync方法讀取您的配置值。
//Read data from file
await Windows.Storage.FileIO.ReadTextAsync(sampleFile);
我們有一個專門的樹莓派堆棧交換 - 試試發佈您的問題那裏https://raspberrypi.stackexchange.com/ –
謝謝。我將這樣做 –
您可以檢查[文件訪問權限](https://docs.microsoft.com/en-us/windows/uwp/files/file-access-permissions)和[讀取文件](https:/ /docs.microsoft.com/en-us/windows/uwp/files/quickstart-reading-and-writing-files#reading-from-a-file)。 –