A
Author #1
One of my asp.net 3.5 web applications tracks all kinds of user files.
Users can upload files to a storage in addition to other file
information which is stored in the SQL Server 2005 Database.
Currently, my design is to store the files in the same SQL Server 2005
database. This is my preferred method. (I may consider storing files
in the file system, and simply keep the path in the database, if my
current problem cannot get resolved nicely.)
I am using this ajax file upload tool to upload files:
http://en.fileuploadajax.subgurim.net/
This tool uploads the file to a temp folder, and when a user clicks on
a Save button, my application reads the uploaded file from this temp
folder and sends it to the database.
The problem:
1) Because more than 1 user may be uploading files at the same time,
and 1 user during 1 session may upload more than 1 file, the system
must be able to identify *the-just-uploaded* files *by the current
user*. I have been successful in doing this by using a Guid plus
SessionID.
2) Immediately after the files are sent to the database, I attempt to
erase all of them from the temp folder, and this is where I am having
problem.
I think I have to erase any file that has been saved to the database
as a cleanup for the next file upload operation.
The problem is, when my application tries to erase the files
immediately after they are saved to the database, I get an exception
which says: The file is being used by another process.
I guess this is because the deletion attempt happens too soon after
the files are saved to the database.
How would you resolve this problem? I am more interested in the
design. In other words, what technique would you use in this kind of
situation to avoid such file read-then-delete conflict?
I hope that this isn't too long and if it is not clear, please yell.
Thanks.
Users can upload files to a storage in addition to other file
information which is stored in the SQL Server 2005 Database.
Currently, my design is to store the files in the same SQL Server 2005
database. This is my preferred method. (I may consider storing files
in the file system, and simply keep the path in the database, if my
current problem cannot get resolved nicely.)
I am using this ajax file upload tool to upload files:
http://en.fileuploadajax.subgurim.net/
This tool uploads the file to a temp folder, and when a user clicks on
a Save button, my application reads the uploaded file from this temp
folder and sends it to the database.
The problem:
1) Because more than 1 user may be uploading files at the same time,
and 1 user during 1 session may upload more than 1 file, the system
must be able to identify *the-just-uploaded* files *by the current
user*. I have been successful in doing this by using a Guid plus
SessionID.
2) Immediately after the files are sent to the database, I attempt to
erase all of them from the temp folder, and this is where I am having
problem.
I think I have to erase any file that has been saved to the database
as a cleanup for the next file upload operation.
The problem is, when my application tries to erase the files
immediately after they are saved to the database, I get an exception
which says: The file is being used by another process.
I guess this is because the deletion attempt happens too soon after
the files are saved to the database.
How would you resolve this problem? I am more interested in the
design. In other words, what technique would you use in this kind of
situation to avoid such file read-then-delete conflict?
I hope that this isn't too long and if it is not clear, please yell.
Thanks.