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

File IO - Access to path "xxx" is denied Error

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 same file name and
must have the same file name. I am essentially overwrite an existing file
that is being used by another user.

My question: Is there some method or property in the IO class that will
allow me to CHECK to see if it is safe to try and write to that file name?

TIA.

Dec 4 '07 #1
6 4558
More likely the problem is in the asp.net process not having enough rights
to access the path.

If the problem is in another user trying to access the file, you can just
try opening the file in a loop for a few seconds with catching exceptions.
But it is not a good idea to make a web application wait for this sort of
things. What is the file for anyway?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:41**********************************@microsof t.com...
>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 same file name
and
must have the same file name. I am essentially overwrite an existing file
that is being used by another user.

My question: Is there some method or property in the IO class that will
allow me to CHECK to see if it is safe to try and write to that file name?

TIA.

Dec 4 '07 #2
On Dec 4, 6:42 pm, Paul <P...@discussions.microsoft.comwrote:
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 same file name and
must have the same file name. I am essentially overwrite an existing file
that is being used by another user.

My question: Is there some method or property in the IO class that will
allow me to CHECK to see if it is safe to try and write to that file name?

TIA.
A common type of error in these kind of programs is that we keep the
file handle open and when we try to access file next time, it gives
you access denied error.
Please check whether you have closed the file handle properly.
Also check whether you can find that file in Task Manager processes
tab ??
These all are guesses and may not apply.
Dec 4 '07 #3
Thanks for your assistance.

No this is the process.

- I grab data and write it to a file.
- That file is then included in an intranet page. A user opens (i.e. reads)
that page and leaves it open in their browser. This "locks" the file (I
think).
- I then grab data again programatically (scheduled task) and I try to
programmatically overwrite the file that is already open by the intranet
user. An error occurs.

I am trying to eliminate the error but first programmatically checking to
determine if the file is "open" or it is not open and I can safely write to
it.

I do not see anywhere for that check. I know I can trap the error but I
would rather not do that.


"Eliyahu Goldin" wrote:
More likely the problem is in the asp.net process not having enough rights
to access the path.

If the problem is in another user trying to access the file, you can just
try opening the file in a loop for a few seconds with catching exceptions.
But it is not a good idea to make a web application wait for this sort of
things. What is the file for anyway?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:41**********************************@microsof t.com...
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 same file name
and
must have the same file name. I am essentially overwrite an existing file
that is being used by another user.

My question: Is there some method or property in the IO class that will
allow me to CHECK to see if it is safe to try and write to that file name?

TIA.


Dec 4 '07 #4
I close the IO StreamWriter right after I am done with the Write. See my
response above to Eliyahu for a more detailed explanation of what I am doing.

Thanks for your assistance.


"coolCoder" wrote:
On Dec 4, 6:42 pm, Paul <P...@discussions.microsoft.comwrote:
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 same file name and
must have the same file name. I am essentially overwrite an existing file
that is being used by another user.

My question: Is there some method or property in the IO class that will
allow me to CHECK to see if it is safe to try and write to that file name?

TIA.

A common type of error in these kind of programs is that we keep the
file handle open and when we try to access file next time, it gives
you access denied error.
Please check whether you have closed the file handle properly.
Also check whether you can find that file in Task Manager processes
tab ??
These all are guesses and may not apply.
Dec 4 '07 #5
- That file is then included in an intranet page. A user opens (i.e.
reads)
that page and leaves it open in their browser. This "locks" the file (I
think).
Once the file has been streamed down to the client's browser, there is no
more connection between the file and the client. The file can't be locked
because of this. I still think you are more likely having permission
problems.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:6A**********************************@microsof t.com...
Thanks for your assistance.

No this is the process.

- I grab data and write it to a file.
- That file is then included in an intranet page. A user opens (i.e.
reads)
that page and leaves it open in their browser. This "locks" the file (I
think).
- I then grab data again programatically (scheduled task) and I try to
programmatically overwrite the file that is already open by the intranet
user. An error occurs.

I am trying to eliminate the error but first programmatically checking to
determine if the file is "open" or it is not open and I can safely write
to
it.

I do not see anywhere for that check. I know I can trap the error but I
would rather not do that.


"Eliyahu Goldin" wrote:
>More likely the problem is in the asp.net process not having enough
rights
to access the path.

If the problem is in another user trying to access the file, you can just
try opening the file in a loop for a few seconds with catching
exceptions.
But it is not a good idea to make a web application wait for this sort of
things. What is the file for anyway?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:41**********************************@microso ft.com...
>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 same file
name
and
must have the same file name. I am essentially overwrite an existing
file
that is being used by another user.

My question: Is there some method or property in the IO class that will
allow me to CHECK to see if it is safe to try and write to that file
name?

TIA.



Dec 5 '07 #6
On Dec 4, 10:59 pm, Paul <P...@discussions.microsoft.comwrote:
Thanks for your assistance.

No this is the process.

- I grab data and write it to a file.
- That file is then included in an intranet page. A user opens (i.e. reads)
that page and leaves it open in their browser. This "locks" the file (I
think).
- I then grab data again programatically (scheduled task) and I try to
programmatically overwrite the file that is already open by the intranet
user. An error occurs.

I am trying to eliminate the error but first programmatically checking to
determine if the file is "open" or it is not open and I can safely write to
it.

I do not see anywhere for that check. I know I can trap the error but I
would rather not do that.

"Eliyahu Goldin" wrote:
More likely the problem is in the asp.net process not having enough rights
to access the path.
If the problem is in another user trying to access the file, you can just
try opening the file in a loop for a few seconds with catching exceptions.
But it is not a good idea to make a web application wait for this sort of
things. What is the file for anyway?
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Paul" <P...@discussions.microsoft.comwrote in message
news:41**********************************@microsof t.com...
>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 same file name
and
must have the same file name. I am essentially overwrite an existing file
that is being used by another user.
My question: Is there some method or property in the IO class that will
allow me to CHECK to see if it is safe to try and write to that file name?
TIA.- Hide quoted text -

- Show quoted text -
Try to create a file and overwrite it without letting user open it. If
it doesn't work - it's a permissions issue.
Dec 5 '07 #7

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

Similar topics

0
by: Juan Irigoyen | last post by:
How I can traduce this sentence in VB. Thanks. Dim arrSesions As DataRow() arrSesions = Context.Cache("SessionKeys").Select("xxx")
4
by: TS | last post by:
I am trying to create a page template. I am trying to set the value of a field to the return value from a method. What do I have to do to get m_form set to the value returned from a method? (the...
11
by: icanoop | last post by:
I would like to do this MyClass x; istringstream("XXX") >> x; // Works in VC++ but not GCC instead of MyClass x; istringstream iss("XXX"); iss >> x; // Works in both GCC and VC++
23
by: lwoods | last post by:
I am trying to pass some info to another page on my site. I set "session_start()" in page 1, assign a session variable to a value, then execute a "header('Location: ....')." But on the target...
4
by: Lloyd Dupont | last post by:
I can't use Control.ResolveUrl because I need to write the conversion in a utility class. However I know the current context. How could I convert the URL to one usable by the user? -- I have...
7
by: sforsasi | last post by:
Hi, I'm trying a simple code to upload a file to the server. When I click to Upload I get the following error message: Error: Access to the path xxx is denied The folder in which I'm trying...
0
by: Robert Dailey | last post by:
I created a basic python file and made an attempt to execute it from the command line, however it gives me a weird error after the python file has been executed: Traceback (most recent call...
4
by: jiatiejun | last post by:
I want to convert a path from ~/xxx/xxx.gif to 'http://xxxxxxx/xxx/xxx.gif' how to convert it? thanks btw: the convert function allow
1
by: Dom | last post by:
This one is a little difficult to explain. I placed a RichTextBox control on my form, I called it chiMain, then I wrote CHITextBox.cs. This class extends the RichTextbox class, and has a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.