Reputation: 112
i want file copy from pictures libary to local folder:
string path = ApplicationData.Current.LocalFolder.Path + "\\files";//error:Additional information: Object reference not set to an instance of an object.
folder = await folder.GetFolderAsync(path);
await file.CopyAsync(folder);
And i got this error:Additional information: Object reference not set to an instance of an object.
What am i doing wrong ?
Upvotes: 0
Views: 1475
Reputation: 81253
GetFolderAsync gets a single sub-folder from the current folder using the specified folder name. In your code, your folder must be null
, you need to initialize it to some value. This should work for you -
StorageFolder folder = ApplicationData.Current.LocalFolder;
folder = await folder.GetFolderAsync("files");
await file.CopyAsync(folder);
Upvotes: 2
Reputation: 77354
Either ApplicationData
is null
or .Current
is null
or .LocalFolder
is null
or .Path
is null
.
You will need to find out which one and correct it.
Upvotes: 0