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 <a href="https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn611857.aspx" rel="nofollow">MSDN</a> tutorial to access sd card in WinRT. I need SD card access in order to store my App's backup & log folders. By following <a href="https://monkeyweekend.wordpress.com/2014/12/09/write-a-file-to-the-sd-card-on-windows-phone-8-1/" rel="nofollow">this</a> tutorial I configured sd card path in emulator and I am using below code to access that path.
returns empty string instead of returning the path which I configured. I enabled
under
and added
. But honestly this
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.
Under each folder
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.
<strong>Edit</strong>: Deadlock problem got solved by adding
in async call as suggested in comment, but sdcard path is still null, How can I get path and create folder there?
Code:
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();
}
Code:
externalDevices.Path
Code:
RemovableStorage
Code:
Capabilities
Code:
FileTypeAssociations
Code:
FileTypeAssociations
Basically I want two folders and one file under my app name folder.
Code:
AppnameFolder -> BackupFolder, LogFolder, Infile
Under each folder
Code:
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.
<strong>Edit</strong>: Deadlock problem got solved by adding
Code:
ConfigureAwait(false)