C
Codemonkey
Hi,
I have a few questions about best practices when it comes to the management
of temporary files. Any thoughts anyone can give would be much appreciated.
Basically, I'm writing a document storage app - a Windows service acts as
the file sotrage server and remote windows forms clients send files to the
server to be stored. The temporary files become involved when a client
wishes to view a file that is stored on the server (the server sends a byte
array containing the file's data, the client writes this to a temporary
location and then executes the viewing application to view the temporary
file).
My queries are:
1) Who should be responsible for deleting the temporary file?
2) If my client is responsible for deleting the file, how do I know if the
user has closed the viewer application?
3) What is the best way to detect changes to the file if the user edits the
document in the viewer application?
My own thoughts so far are:
1) My client app is responsible for deleting the file (wishful thinking that
it isn't
2) When I launch the process to view the file, I keep track of it and delete
the temp file when the process exits. The problem with this is what do I do
if the user exits my application before they exit the viewer application?
Also, what happens if they keep the viewer open, but opens another file
unrelated to my application?
3) Use FileSystemWatcher to watch the file for changes. Again, what happens
if the user exits my application before exiting the viewer?
Any thoughts would be appreciated,
Best Regards,
Trev.
I have a few questions about best practices when it comes to the management
of temporary files. Any thoughts anyone can give would be much appreciated.
Basically, I'm writing a document storage app - a Windows service acts as
the file sotrage server and remote windows forms clients send files to the
server to be stored. The temporary files become involved when a client
wishes to view a file that is stored on the server (the server sends a byte
array containing the file's data, the client writes this to a temporary
location and then executes the viewing application to view the temporary
file).
My queries are:
1) Who should be responsible for deleting the temporary file?
2) If my client is responsible for deleting the file, how do I know if the
user has closed the viewer application?
3) What is the best way to detect changes to the file if the user edits the
document in the viewer application?
My own thoughts so far are:
1) My client app is responsible for deleting the file (wishful thinking that
it isn't
2) When I launch the process to view the file, I keep track of it and delete
the temp file when the process exits. The problem with this is what do I do
if the user exits my application before they exit the viewer application?
Also, what happens if they keep the viewer open, but opens another file
unrelated to my application?
3) Use FileSystemWatcher to watch the file for changes. Again, what happens
if the user exits my application before exiting the viewer?
Any thoughts would be appreciated,
Best Regards,
Trev.