locked
Files being removed by "hosting program" shortly after they've been opened by mine.

    Question

  • Hi,

    I am having a problem with files from certain locations, opened in my App.

    My app is a PDF Reader. When I open a file, I open a RandomAccessStream in Read mode that I keep open while the app is running. If the user modifies the document and saves, then I close the Read stream and open a ReadWrite stream, write to the file, close the ReadWrite stream and reopen it in Read mode.

    This works fine for most documents. However, when you open a document from OneNote (desktop version) or from Outlook (there's probably more) they put the file in a temporary location, activate the default app (mine in this case) and then they remove the file again about 5 seconds later. This causes some major problems for my app.

    Now, it would be easy enough to open these documents in ReadWrite mode, or copy them somewhere first. The problem is that I don't know how to identify these documents. I can check the path, but there might be more programs like this that use different locations, or their own locations. The user could also change their temp path environment variable, putting it somewhere completely different.

    So, is there a recommended way to deal with these things?

    Best Regards,

    Tomas Hofmann

    Friday, November 28, 2014 11:37 PM

Answers

  • Hi James,

    I do agree. I was just not sure how to recognize this type of file. I then found the Attributes property that tells me the document is temporary. So now I create a local copy of the file in the apps temp folder, prompting them to use Save As if they modify it.

    So it all works now.

    Thanks for your time James.

    Best Regards,

    Tomas Hofmann

    • Marked as answer by T Hofmann Wednesday, December 17, 2014 9:08 PM
    Wednesday, December 17, 2014 9:08 PM

All replies

  • Hi Tomas,

    Let's say if you make the app like following scenario, it should be easier to implement the app.

    1, User select the file by using File Picker

    2, Your app copy the file to local folder or temp folder

    3, Let user modify the copied file

    4, Let user save the file by Save Picker instead of saving for them.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 01, 2014 9:45 AM
    Moderator
  • Hi James,

    That seems like a pretty awkward way to use the app. Imagine a word processor without a Save (only a Save As) button. Furthermore, in my case, the problem is with documents from other apps. Double clicking on an attachment in certain apps (Outlook, OneNote) will launch whatever the default for that file type is.

    Also, a lot of documents are fairly substantial in size. Not sure I want a local copy of it, or to load the whole thing to memory.

    For example, Microsoft's reader seems to recognize that the file is from a OneNote, and therefore will not give you a regular save option. That is, they know it will not be available for long. The question is; how. And is whatever they're doing a practical approach?

    As a general question, is there a better way to handle these types of things than to check the file location and building up an understanding of where every other app stores files that they let you open, and which ones you can save to and which ones you can't?

    Anyhow, always using a save picker is not an option. Rather, I need some way to know when the file can be used continually and when it needs to be copied first.

    Ideally, it doesn't come down to checking the path and manually learning which programs can and can't be trusted to leave the file for you.

    Best Regards,

    Tomas Hofmann

    Monday, December 01, 2014 10:40 PM
  • Hi Tomas,

    Yes, I agree, save button is far more important than save as button.

    However, when you open a document from OneNote (desktop version) or from Outlook (there's probably more) they put the file in a temporary location, activate the default app (mine in this case) and then they remove the file again about 5 seconds later. .

    Actually i'm interested with how you can see the file was in a temporary location?

    I created a test app and i can see following things:

    Why you think you open a copy instead of open a file, the only possibility might be the file is used by some other apps and to avoid conflict, system give you a copy.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, December 03, 2014 10:06 AM
    Moderator
  • Hi James,

    I get the following from opening a file from OneNote (Note that this is the desktop version):

    I did notice however the Attribute field. So it might be that the entire topic was kind of silly. It says right there that it is temporary, so I need to copy it to my temp folder and then treat it as a read only document.

    I will test this and see how it goes. Makes you feel somewhat silly... :)

    Thanks for your help James.

    Tomas

    Tuesday, December 09, 2014 6:54 PM
  • Hi Tomas,

    I consulted with our seniors and I just recognize your scenario looks a bit unreasonable.

    Let me explain to you, as we know OneNote or Outlook is kind of server-client mode application, all your files are located on the remote server side.

    The file we are using in our client is kind of COPY from server, you may noticed that some of the file will be synchronized to server but the function is implemented by some service, a good sample is if you put the file in your OneDrive folder, the service will synchronized with server automatically but if you put the file somewhere else, the service would not able to know that.

    And as you also see the file you opened are comes from a Temp folder but not like mine(I tested with a local onenote file, therefore the folder path is not a temp folder), the purpose for 5 second you mentioned here is give user/client enough time to load file to the memory, then system thought these files are not required any more and delete them.

    For these consideration, I think the Save button for Outlook and OneNote file is not reasonable in your scenario, will you agree with this?

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, December 10, 2014 6:58 AM
    Moderator
  • Hi James,

    I do agree. I was just not sure how to recognize this type of file. I then found the Attributes property that tells me the document is temporary. So now I create a local copy of the file in the apps temp folder, prompting them to use Save As if they modify it.

    So it all works now.

    Thanks for your time James.

    Best Regards,

    Tomas Hofmann

    • Marked as answer by T Hofmann Wednesday, December 17, 2014 9:08 PM
    Wednesday, December 17, 2014 9:08 PM