473,385 Members | 1,912 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,385 software developers and data experts.

File access exceptions

I've got some ASP.net pages that write files for use as attachments
(actually I have other pages that either create or destroy temporary files
where this is just as pertinent). I generally have no problem either
creating the file or reading from and existing file, but when I go to do the
next step either writing to the newly created file or destroying the deleted
file I often encounter an exception something along the line of:

The process cannot access the file "c:\foo.txt" because it is being used by
another process.

Is there anyway I can test for this condition and wait for a period of time?

I have these statements in try/catch blocks, that are nested within a while
blocks, the while block has conditions for success and number of trys, so
the while block can exit with an unsuccessful attempt if it takes more than
10 tries or whatever I set it for.

Is there a better way?
Jul 19 '05 #1
0 1164

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

Similar topics

5
by: Hans-Joachim Widmaier | last post by:
Recently, there was mentioned how someone who had understood Python's error handling would write the "open and read file with error handling" idiom. If I remember correctly, it went like this: ...
9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
2
by: Holger | last post by:
Hello everyone, is there a way to check if a file is in use by another program. One possibility would be to poll the file for an exclusive lock, but this has very bad consequences for the...
8
by: Gabe Moothart | last post by:
Hi, I'm writing a windows service which interacts with a separate process. Basically, it calls a process which creates a file, and then my service reads that file. The problem is, the external...
4
by: csgraham74 | last post by:
Hi guys, Im attempting to connect my asp.net solution to an ms access backend database. Everything is working fine locally but when i upload i get the error "exception has been thrown by the...
4
by: hkappleorange | last post by:
I ued this code to connect to a mdb file A = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=C:\Inetpub\wwwroot\ASPX\Authors.mdb" )
2
by: Jim Heavey | last post by:
Just a couple of general questions about errors related to accessing drives. I seem to remember in VB6 there were a list of error numbers you could test for when you attempted to access a drive,...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
0
by: vinoj1100 | last post by:
print "Content-Type: text/html\n" form = cgi.FieldStorage() item = form.file data = item.file.read() print data...
6
by: =?Utf-8?B?UGF1bA==?= | last post by:
I am getting an "Access to the path "xxxx" is denied error. I believe is because the file that I am writing to programatically is being read/written to by another end user. These files have the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.