views:

34

answers:

2

I am working on a license management type application that copies a password protected zip file to the applications root. The user clicks a button "Open Presentation" and the zipped file is extracted into the root folder and then I use the Office interop to open the file in Powerpoint. At this point to my surprise I am able to delete the extracted file that is currently open in the Powerpoint application. I had assumed that trying to delete the file would fail as the file is still open in Powerpoint.

Why is it allowing me to delete the file? Is the file somehow copied to a temp folder and then opened in PowerPoint?

Can I move forward with the application relying on this ability to delete the file as soon as it is opened in Powerpoint? This would be optimal because it helps insure that the file cannot be copied(I am also using the xml to stop "Save As" and "Save" from appearing int Powerpoint).

Thanks for the insight, John

+3  A: 

Many applications do not keep the file open after they loaded it into memory. Possibly this is the case with powerpoint as well. Also, some operating systems let you delete open files unless they are specifically locked. Many unix systems exhibit such behavior.

As for you purposes, what would stop the user to just save the power point file into different location?

Also, in the future power point might keep the file open after they read into memory

Vlad
What stops the user is the fact that the only way to unzip the secure file is to run the application that I produced. As soon as the file is unzipped it is opened in Powerpoint and then the unzipped file is immediately deleted, thus giving the user a very small window to find the file and copy it(very low risk for 90% of users). Your last statement raises a new question:If I am referencing a specific version of the Office Powerpoint interop will it be affected by future or prior versions of Powerpoint on th users machine?
John Maloney
But then the user can just use power point to save your file. As for your last question I say it probably will. The Office COM spec doesn't mention anything about semantics of the "File Open" operation. So microsoft is free to act either way. The interop version is mapped to the COM version. Usually same application handles the interop calls for all versions. The version only affects the which methods and which parameters are exposed by certain intefaces. In rare cases the behavior of the application could also depend on which version of the interface you are using, but this is up to M$.
Vlad
I am using Office 2007's ability to turn off menu items to stop the user from having any options to "Save" or "Save As". Thanks for the COM information.
John Maloney
A: 

Even if this specific version of PowerPoint doesn't fail when this specific file is deleted while it's open, I wouldn't rely on that behavior for future (or past) versions of Powerpoint, nor for other (larger? containing OLE links?) files. Remember that everything you're working with is basically documented by "reference implementation".

To be frank, your application sounds like an annoying technical solution to a social problem.

Derrick Turk