I am very much confused with WP 8.1 (runtime) SD card access. I am trying to create a folder in WP 8.1 (Runtime) Sd Card, but unable to do so. I am following MSDN tutorial to access sd card in WinRT. I need SD card access in order to store my App's backup & log folders. By following this tutorial I configured sd card path in emulator and I am using below code to access that path.
private async Task<string> AsyncExternalStoragePath()
{
// Get the logical root folder for all external storage devices.
Windows.Storage.StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;
// Get the first child folder, which represents the SD card.
StorageFolder sdCard = (await externalDevices.GetFoldersAsync().AsTask().ConfigureAwait(false)).FirstOrDefault();
}
externalDevices.Path
returns empty string instead of returning the path which I configured. I enabled RemovableStorage
under Capabilities
and added FileTypeAssociations
. But honestly this FileTypeAssociations
are very much confusing to me. I read many articles, but I am not yet clarified fully.
Basically I want two folders and one file under my app name folder.
AppnameFolder -> BackupFolder, LogFolder, Infile
Under each folder
Backup -> To keep last five backup files (.db)
Log -> To create log files per day basis (.txt)
inifile -> To enable logging
If I know how to create a custom folder (app name folder) in sd card, I would create sub-folders (backup, log) easily. But right now I am stuck in getting the root path.
Edit: Deadlock problem got solved by adding ConfigureAwait(false)
in async call as suggested in comment, but sdcard path is still null, How can I get path and create folder there?