locked
read/write file from the custom location in metro style app RRS feed

  • Question

  • Hi

    In metro style app, I know how to read/write file from the known folder location i.e. document, picture etc by using KnownFolders class.

    But i want to read/write file from the custom location i.e. E:\myDataFiles\data.txt. 



    Ravi Shankar

    Friday, June 22, 2012 11:16 AM

Answers

  • You have to use file or folder picker mechanism. For example, you can propose your user to select data folder using FolderPicker and once you have a handler to that folder you can read/write/create files located in the folder. Additionally, you can use Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList to register StorageFolder object associated with the folder to be able to access it later.
    Friday, June 22, 2012 12:25 PM
  • Than you have two options: store your data in local data folder (Windows.Storage.ApplicationData.Current.LocalFolder) or use one of the known folders. The rest of hard drive is not available for WinRT app.
    Friday, June 22, 2012 1:53 PM

All replies

  • You have to use file or folder picker mechanism. For example, you can propose your user to select data folder using FolderPicker and once you have a handler to that folder you can read/write/create files located in the folder. Additionally, you can use Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList to register StorageFolder object associated with the folder to be able to access it later.
    Friday, June 22, 2012 12:25 PM
  • Hi

    But we don't want to give the option to pick the file to user.


    Ravi Shankar

    Friday, June 22, 2012 1:09 PM
  • Than you have two options: store your data in local data folder (Windows.Storage.ApplicationData.Current.LocalFolder) or use one of the known folders. The rest of hard drive is not available for WinRT app.
    Friday, June 22, 2012 1:53 PM