Temporary Files

  • Thread starter Harsh Vardhan Singh
  • Start date
H

Harsh Vardhan Singh

hi,

i am trying to create a temporary file associated with a particular process.
For instance, i have a windows application which will create a temp file as
soon as it this program is executed. Now i want this temp file to be
destroyed if this application is closed / crashes. Is this possible?

Please help.
Thanks in advance,
Harsh
 
R

richlm

Does it need to be a physical file on disk?
If not, maybe you could use MemoryStream?
 
H

Harsh Vardhan Singh

yes it has to be on the physical disk.. i think it wud help if i explain
what i am trying to do... basically i hv to prevent a file from being
accessed by two users (on different pcs) simultaneously.. so i want to
create a temp file as soon as one user accesses that file.. now when someone
else tries to open it, i first check if the temp file is present or not...

now the problem is removing the temp file in case the program crashes... coz
if the file is not removed then no user will be able to access it unless the
temp file is manually deleted.

this is why i wanted to know if there can be temp files created and
destroyed along with a process.

harsh.
 
A

Amit Bahree

If you need to create more than one file, then you can use
TempFileCollection class found in the System.CodeDom.Compiler namespace.
On MSDN (installed locally) you can find out more at
ms-help://MS.VSCC.2003/MS.MSDNQTR.2005JAN.1033/cpref/html/frlrfsystemcodedomcompilertempfilecollectionclasstopic.htm

HTH,
Amit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top