473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Temp Files

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
Nov 16 '05 #1
3 7259
Did you try deleting the temp file in the Dispose and finalizer
methods? You can have a class representing the temp file. The Dispose
method would delete the file and you'd call this method in normal
situations. For abnormal situations, the finalizer would get called by
the CLR and would delete the file.

Regards
Senthil

Nov 16 '05 #2

I don't think it's possible with pure .NET code but is possible with a
p/invoke call to CreateFile with FILE_ATTRIBUTE_TEMPORARY and
FILE_FLAG_DELETE_ON_CLOSE flags. You can then create a FileStream
from the result with the IntPtr constructor and use the like you would
a natively created .NET FileStream.

HTH,

Sam
On Fri, 4 Mar 2005 00:00:47 +0530, "Harsh Vardhan Singh"
<ha*******************@yahoo.com> wrote:
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


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
Nov 16 '05 #3
thanx for the suggestions but i still hvnt been able to solve the problem
:( ... 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...if it is, then i dont allow the other
user to access the file... this part is fine... but 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 again unless the temp file is
manually deleted....
i tried creating a class which represents this file and tried to delete the
temp file in the dispose function.. but the file wasnt deleted in case of
program crashing...

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

thanx again for the help
harsh

"Harsh Vardhan Singh" <ha*******************@yahoo.com> wrote in message
news:O6*************@TK2MSFTNGP15.phx.gbl...
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

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bart Plasmeijer | last post by:
Hi, I did create .net application that is using .net remoting. When I start the application temp (.tmp) files are created into the "windows\temp" folder. When I close the application the tmp...
3
by: James Proctor | last post by:
Hi there, im brand new to ASP. Ive done loads of VB coding and one of my clients is intrested in a web based application, so im trying to play on and learn it a tad. However im comming across lots...
17
by: Jon Ole Hedne | last post by:
I have worked on this problem some hours now (read many-many...), and I can't solve it: In vba-code I create a table with Connection.Execute, and add some data to it. This table is saved in the...
0
by: John Baker | last post by:
Hi; I am have a db back end situation, and have a problem with temp files. I am attempting to use temp files to manage the modification of a master file, and its not working right. I set up...
0
by: Jeff Dillon | last post by:
When I browse to a simple .aspx page, I get the error: Unable to create temp file in path 'c:\windows\system32\inetsrv\%SystemRoot%\TEMP\': The directory name is invalid. My TEMP variable is...
1
by: James Proctor | last post by:
Hi there, im brand new to ASP. Ive done loads of VB coding and one of my clients is intrested in a web based application, so im trying to play on and learn it a tad. However im comming across lots...
10
by: robwharram | last post by:
Hi, I'm quite frustrated in the fact that I can't even display a simple "Hello World" message on .Net. I've been through all of the groups and searched all over the place and haven't been able...
4
by: robert d via AccessMonster.com | last post by:
When my app starts up, it creates a temporary database. This temp database is created from a 'model' database that is in the same folder as the application. Because there is a model, the creation...
2
by: Mayer, Stefan | last post by:
Hi, for some other reasons, where i have no influence and no possibility to change it; it is necessary to upload files tempoarily to a temp-folder in my web-project. Allthough the files are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.