locked
Using folders to store files

    Question

  • I'm developing a test windows store app to open a template file (a simple .txt file with place holder for few fields like [FirstName]) and generate another txt file based on this template.

    If I develop this application in windows form, I can have the user to set the default folder for the source template and the destination folder for the generated files in the settings area, and the app can generate the files without the intervention of the user. The Windows form can access the drives also. I can use clickonce to create an install the app.

    I believe the above pattern that I can use for a Windows form should be changed to work in a windows store app. If so, I should be using cloud to store the template and the generated files, so if the user uses a different device he can access the generated files from the template. The security wont be an issue also because the app will chose to work with cloud or skydrive where the user has access.

    But what if I have to work disconnected and later sync with skydrive or cloud? My first qn is what storage mechanism I should use to do disconnected operation. Can I access the C drive as I can with a Windows Form? The second question is, will my app be approved to put in the windows store by considering the fact that the app is accessing the system drives which can be a security risk?

    Appreciate the feedback.




    Sunday, February 16, 2014 11:35 PM

Answers

  • You can do basically the same thing as you do in your WinForms app: use a FolderPicker to let the user choose a folder to use and then save things there.

    Windows Store apps cannot read or write arbitrary locations without the user's permission, but the user can choose to access any location that the user has permission for.

    --Rob

    Monday, February 17, 2014 2:52 AM
    Owner

All replies

  • You can do basically the same thing as you do in your WinForms app: use a FolderPicker to let the user choose a folder to use and then save things there.

    Windows Store apps cannot read or write arbitrary locations without the user's permission, but the user can choose to access any location that the user has permission for.

    --Rob

    Monday, February 17, 2014 2:52 AM
    Owner
  • Hi ,

    The only this that you can try is to create  folders by your own , add them in your futureaccesslist and then use them to do the job you want. Because since you add them in your futureaccess list you are giving permission to your app to use those folders and of course do whatever you like in there.

    For example

    private StorageFolder m_downloadfolder;

     public StorageFolder Download_Folder
            {
                get { return m_downloadfolder; }
                set { m_downloadfolder = value; }
            }

    if (StorageApplicationPermissions.FutureAccessList.Entries.Count() >= 1000)
                    {
                        StorageApplicationPermissions.FutureAccessList.Clear();
                    }

                    // Check if we create this folder before, if not create it
                    if (StorageApplicationPermissions.FutureAccessList.Entries.Any(item => item.Metadata == "MyFolder"))
                    {
                        // if we have the folder in the FutureAccessList, just ui
                        var entry = StorageApplicationPermissions.FutureAccessList.Entries.FirstOrDefault(item => item.Metadata == "MyFolder");
                        Download_Folder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(entry.Token);
                    }
                    else
                    {
                        Download_Folder = await DownloadsFolder.CreateFolderAsync("MyFolder");
                        StorageApplicationPermissions.FutureAccessList.Add(Download_Folder, "MyFolder");
                    }

    Now you have a download_folder and you can read and write from inside your app.

    Hope that helped you

    thank you

    Monday, February 17, 2014 1:35 PM