By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,368 Members | 1,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,368 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
- 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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.