How to get an IStorageFolder object from a StorageFile object RRS feed

  • Question

  • We implement the feature of saving screenshot to an image file using the ScreenGrab function in DirectXTK. In order to the solve the file system access permission issue, we follow the suggestion in this post (http://directxtk.codeplex.com/discussions/402169) to first save the image file to the temporary app data store, and then copy this temporary file to the folder users select via FileSavePicker. Now we have issue in doing the last step, that is, given a StorageFile object representing the temporary file and the full pathname the user specifies (e.g. Picture Library/screenshot.png), how can we copy the temporary file to the user selected folder (in this case, "Picture Library) using StorageFile::CopyAsync? This function expect a reference to IStorageFolder object, and we only have a StorageFile object.
    Wednesday, November 7, 2012 3:49 PM


  • If the goal is to copy the file from the temporary data store to the location chosen by the user then you don't need a StorageFolder, just a StorageFolder for the original and target locations. Take a look at StorageFile's CopyAndReplaceAsync | copyAndReplaceAsync method.


    • Marked as answer by Leonard Thursday, November 8, 2012 12:43 AM
    Wednesday, November 7, 2012 8:27 PM

All replies