Zugriff auf die Dateien des Systemlaufwerks (C, D) in UWP AppService. Beispiel: Ich möchte auf die Datei "C: \ Test \ sample.txt" von UWP AppServices zugreifen.Zugriff auf C-Laufwerkdateien in UWP AppService
Ich habe den folgenden Code ausprobiert. aber Wurffehler (Zusatzinformation: Zugriff verweigert.). Außerdem wurden die "Removable Storage" -Kapazitäten in der appxmanifest-Datei hinzugefügt.
StorageFolder testfolder = await StorageFolder.GetFolderFromPathAsync(@"c:\\test");
StorageFile sourcefile = await testfolder.GetFileAsync("sample.txt");
StorageFile destinationfile = await KnownFolders.SavedPictures.CreateFileAsync("Mysample.txt");
using (var sourcestream = (await sourcefile.OpenReadAsync()).GetInputStreamAt(0))
{
using (var destinationstream = (await destinationfile.OpenAsync(FileAccessMode.ReadWrite)).GetOutputStreamAt(0))
{
await RandomAccessStream.CopyAndCloseAsync(sourcestream, destinationstream);
}
}