I am working on a small UWP
app that will take pictures and video and save it at a desired location on the PC.
Here is the code base I am using https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/CameraStarterKit/cs/MainPage.xaml.cs
When I try to initialize StorageFolder
class with a desired path, it comes out as null. It only supports to initialize with following paths
var picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Documents);
var picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music);
var picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);
var picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Videos);
Here is my code:
private StorageFolder _captureFolder = null;
_captureFolder = picturesLibrary.SaveFolder ?? ApplicationData.Current.LocalFolder;
var file = await _captureFolder.CreateFileAsync("SmartPhoto.jpg",
CreationCollisionOption.GenerateUniqueName);
var picturesLibrary = await Task.Run(() =>
System.IO.File.Move(file.Path, @"C:\Temp\Pictures\" + file.Name));
Since StorageFolder
is not initializing for C:\Temp\Pictures
, I tried to move that file from KnownLibraryId.Pictures
to C:\Temp\Pictures
and that fails too,
System.UnauthorizedAccessException: 'Access to the path 'C:\Temp\Pictures' is denied.'