locked
Folder restrictions and folder path RRS feed

  • Question

  • Hi,

    I have made an app where the user can open a pdf-file (via FileOpenPicker). Then the user can write some canvas images on it the pdf-file. When the user saves the canvas drawing I save the drawing as a separate serialized file under the local app folder which holds a reference to the pdf-file. When the user opens the canvas drawing file again I also open the pdf-file. This works fine as long as the pdf document is located in a known folder which the app has right to access. However - sometimes the pdf files that the user opening is located in a "not-known" folder.

    So - is there any way to force the FileOpenPicker to only show the Document folder (I know I can set suggested folder)?

    If that is not possible I was thinking about warning the user if the newly open pdf-file is in another directory than Document folder. The problem is that I dont know how to check if a newly open document (via FileOpenPicker) is located in a specific folder. Of course - could check the file path but it start with c:\\... and I cant be sure that that will be the case for everyone when I try matching folder paths.

    Any suggestions?

    Thomas

    Tuesday, October 30, 2012 1:45 PM

Answers

All replies

  • I don't think you can set a restriction like that on the file picker.  I am not sure if there is some other file picker UI that you could place on your canvas that would display the folder tree,  but it sounds like you need something other that FileOpenPicker for your UI.  If pressed, you could theoretically do this yourself.  Since you have access to the Documents folder, you display all the folders therein to the user who can then pick the right file.


    KeepMyIdentities, Your Key to Password Security. Available now on the Windows Store: http://apps.microsoft.com/webpdp/en-US/app/keepmyidentities/61a9f340-97ac-4666-beab-39f9246cb6fa

    Tuesday, October 30, 2012 1:57 PM
  • Thank you - but I don't want to create my own file picker.

     So if that is not possible - is there any way to check if a newly open file is located in one of the known folders?

    Tuesday, October 30, 2012 2:03 PM
  • once a user gived you access to a file with the filepicker you can cache this access with this namespace: http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.accesscache.aspx

    it allows you to reopen the file whenever you want


    Solutions Developer - Windows Store Apps Using C#

    Tuesday, October 30, 2012 2:19 PM
  • That is great!

    - Will that work even if the file is located in SkyDrive?

    - Can I save the cached fileaccess in the roaming folder and reuse the access from another device (using the same windows account of course)? That is for the scenario where you have a central file location where the path is the same from both devices (like I assume SkyDrive would be).

    - If I use the cached folder access - I assume I dont have to declare manifest capabilities for those folders?

    Tuesday, October 30, 2012 2:42 PM
  • 1) Not sure, you need to test it

    2) No, you are not able to roam cached file access

    3) Correct, you don't need to declare any special capabilities

    Tuesday, October 30, 2012 2:46 PM
  • - Will that work even if the file is located in SkyDrive? => no idea. sounds it should but scary as well. give it a try

    - Can I save the cached fileaccess in the roaming folder and reuse the access from another device (using the same windows account of course)? That is for the scenario where you have a central file location where the path is the same from both devices (like I assume SkyDrive would be).

    No its a local thing

    - If I use the cached folder access - I assume I dont have to declare manifest capabilities for those folders?

    No you dont habe to declare the manifest capabilities but then you cant use the knownfolders (be aware of that) you only get access with the filepicker (and yes the user can select a file from a library ofcours with that.)


    Solutions Developer - Windows Store Apps Using C#

    Tuesday, October 30, 2012 2:47 PM
  • Unforunately, I don't think so.  You can check this yourself by running this test code on your machine:

    StorageFolder fold = await StorageFolder.GetFolderFromPathAsync(C:\\Users\\YourName\\Documents");
    if (!Windows.Storage.KnownFolders.DocumentsFolder.FolderRelativeId == fold.FolderRelativeId)
    {
      throw new Exception("Libraries are not folders");
    }


    KeepMyIdentities, Your Key to Password Security. Available now on the Windows Store: http://apps.microsoft.com/webpdp/en-US/app/keepmyidentities/61a9f340-97ac-4666-beab-39f9246cb6fa

    Tuesday, October 30, 2012 2:47 PM
  • Thank you!

    By the way - is it possible for the user to clear this cache?

    Thomas

    Tuesday, October 30, 2012 4:43 PM
  • Just to confirm - it does work with skydrive.

    Thomas

    Tuesday, October 30, 2012 7:50 PM