473,786 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

deleting file - access denied

MA
Hi all!

I created a webservice that check folder for incoming and outgoing files. If
a file exists in my inbox (incoming file) I read it and want to delete it.
It looks like this:

foreach(FileInf o fname in folder.GetFiles ())
{
if(fname.Exists )
{
myStream = new StreamReader(fn ame.FullName,En coding.Default) ;

string line = myStream.ReadLi ne();
while(line != null)
{
content += line;
line = myStream.ReadLi ne();
}
myStream.Close( );

fname.Delete();
}
It works except for fname.Delete();
I get an access denied on this. The file is not read-only if I check
properties in Explorer.

How can I fix this?

/Marre
Nov 16 '05 #1
12 2180
Hi,

Most probably another process is accesing the file. It can even be your
same process !
IF you use a FileSystemWatch er it may generate more than one event for a
"change" depending of what events you are using.

Go to sysinternals.co m and download the file monitoring tool they have, you
will know what process is using what file
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"MA" <ne**@supremeli nk.se> wrote in message
news:2q******** ****@uni-berlin.de...
Hi all!

I created a webservice that check folder for incoming and outgoing files. If a file exists in my inbox (incoming file) I read it and want to delete it.
It looks like this:

foreach(FileInf o fname in folder.GetFiles ())
{
if(fname.Exists )
{
myStream = new StreamReader(fn ame.FullName,En coding.Default) ;

string line = myStream.ReadLi ne();
while(line != null)
{
content += line;
line = myStream.ReadLi ne();
}
myStream.Close( );

fname.Delete();
}
It works except for fname.Delete();
I get an access denied on this. The file is not read-only if I check
properties in Explorer.

How can I fix this?

/Marre

Nov 16 '05 #2
MA
Thanx for the quick answer!

I will check this right now!

/Marre
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:Oi******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

Most probably another process is accesing the file. It can even be your
same process !
IF you use a FileSystemWatch er it may generate more than one event for a
"change" depending of what events you are using.

Go to sysinternals.co m and download the file monitoring tool they have,
you
will know what process is using what file
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"MA" <ne**@supremeli nk.se> wrote in message
news:2q******** ****@uni-berlin.de...
Hi all!

I created a webservice that check folder for incoming and outgoing files.

If
a file exists in my inbox (incoming file) I read it and want to delete
it.
It looks like this:

foreach(FileInf o fname in folder.GetFiles ())
{
if(fname.Exists )
{
myStream = new StreamReader(fn ame.FullName,En coding.Default) ;

string line = myStream.ReadLi ne();
while(line != null)
{
content += line;
line = myStream.ReadLi ne();
}
myStream.Close( );

fname.Delete();
}
It works except for fname.Delete();
I get an access denied on this. The file is not read-only if I check
properties in Explorer.

How can I fix this?

/Marre


Nov 16 '05 #3
Hi,

Most probably another process is accesing the file. It can even be your
same process !
IF you use a FileSystemWatch er it may generate more than one event for a
"change" depending of what events you are using.

Go to sysinternals.co m and download the file monitoring tool they have, you
will know what process is using what file
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"MA" <ne**@supremeli nk.se> wrote in message
news:2q******** ****@uni-berlin.de...
Hi all!

I created a webservice that check folder for incoming and outgoing files. If a file exists in my inbox (incoming file) I read it and want to delete it.
It looks like this:

foreach(FileInf o fname in folder.GetFiles ())
{
if(fname.Exists )
{
myStream = new StreamReader(fn ame.FullName,En coding.Default) ;

string line = myStream.ReadLi ne();
while(line != null)
{
content += line;
line = myStream.ReadLi ne();
}
myStream.Close( );

fname.Delete();
}
It works except for fname.Delete();
I get an access denied on this. The file is not read-only if I check
properties in Explorer.

How can I fix this?

/Marre

Nov 16 '05 #4
MA
Thanx for the quick answer!

I will check this right now!

/Marre
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:Oi******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

Most probably another process is accesing the file. It can even be your
same process !
IF you use a FileSystemWatch er it may generate more than one event for a
"change" depending of what events you are using.

Go to sysinternals.co m and download the file monitoring tool they have,
you
will know what process is using what file
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"MA" <ne**@supremeli nk.se> wrote in message
news:2q******** ****@uni-berlin.de...
Hi all!

I created a webservice that check folder for incoming and outgoing files.

If
a file exists in my inbox (incoming file) I read it and want to delete
it.
It looks like this:

foreach(FileInf o fname in folder.GetFiles ())
{
if(fname.Exists )
{
myStream = new StreamReader(fn ame.FullName,En coding.Default) ;

string line = myStream.ReadLi ne();
while(line != null)
{
content += line;
line = myStream.ReadLi ne();
}
myStream.Close( );

fname.Delete();
}
It works except for fname.Delete();
I get an access denied on this. The file is not read-only if I check
properties in Explorer.

How can I fix this?

/Marre


Nov 16 '05 #5
Check the security setting of the folder. It should have "Modify"
permissions to everyone user.

Dalvir Singh
"MA" <ne**@supremeli nk.se> wrote in message
news:2q******** ****@uni-berlin.de...
Hi all!

I created a webservice that check folder for incoming and outgoing files. If a file exists in my inbox (incoming file) I read it and want to delete it.
It looks like this:

foreach(FileInf o fname in folder.GetFiles ())
{
if(fname.Exists )
{
myStream = new StreamReader(fn ame.FullName,En coding.Default) ;

string line = myStream.ReadLi ne();
while(line != null)
{
content += line;
line = myStream.ReadLi ne();
}
myStream.Close( );

fname.Delete();
}
It works except for fname.Delete();
I get an access denied on this. The file is not read-only if I check
properties in Explorer.

How can I fix this?

/Marre

Nov 16 '05 #6
Check the security setting of the folder. It should have "Modify"
permissions to everyone user.

Dalvir Singh
"MA" <ne**@supremeli nk.se> wrote in message
news:2q******** ****@uni-berlin.de...
Hi all!

I created a webservice that check folder for incoming and outgoing files. If a file exists in my inbox (incoming file) I read it and want to delete it.
It looks like this:

foreach(FileInf o fname in folder.GetFiles ())
{
if(fname.Exists )
{
myStream = new StreamReader(fn ame.FullName,En coding.Default) ;

string line = myStream.ReadLi ne();
while(line != null)
{
content += line;
line = myStream.ReadLi ne();
}
myStream.Close( );

fname.Delete();
}
It works except for fname.Delete();
I get an access denied on this. The file is not read-only if I check
properties in Explorer.

How can I fix this?

/Marre

Nov 16 '05 #7
MA
Well, my knowledge level of these permission-things are really low.

Where can I set this permission on my folder? When I rightclick on my folder
and choose properties, I can´t set any permissions . Is there another way?

/Marre
"Dalvir Singh" <da**********@s ofthome.net> wrote in message
news:uj******** ******@TK2MSFTN GP09.phx.gbl...
Check the security setting of the folder. It should have "Modify"
permissions to everyone user.

Dalvir Singh
"MA" <ne**@supremeli nk.se> wrote in message
news:2q******** ****@uni-berlin.de...
Hi all!

I created a webservice that check folder for incoming and outgoing files.

If
a file exists in my inbox (incoming file) I read it and want to delete
it.
It looks like this:

foreach(FileInf o fname in folder.GetFiles ())
{
if(fname.Exists )
{
myStream = new StreamReader(fn ame.FullName,En coding.Default) ;

string line = myStream.ReadLi ne();
while(line != null)
{
content += line;
line = myStream.ReadLi ne();
}
myStream.Close( );

fname.Delete();
}
It works except for fname.Delete();
I get an access denied on this. The file is not read-only if I check
properties in Explorer.

How can I fix this?

/Marre


Nov 16 '05 #8
MA
Well, my knowledge level of these permission-things are really low.

Where can I set this permission on my folder? When I rightclick on my folder
and choose properties, I can´t set any permissions . Is there another way?

/Marre
"Dalvir Singh" <da**********@s ofthome.net> wrote in message
news:uj******** ******@TK2MSFTN GP09.phx.gbl...
Check the security setting of the folder. It should have "Modify"
permissions to everyone user.

Dalvir Singh
"MA" <ne**@supremeli nk.se> wrote in message
news:2q******** ****@uni-berlin.de...
Hi all!

I created a webservice that check folder for incoming and outgoing files.

If
a file exists in my inbox (incoming file) I read it and want to delete
it.
It looks like this:

foreach(FileInf o fname in folder.GetFiles ())
{
if(fname.Exists )
{
myStream = new StreamReader(fn ame.FullName,En coding.Default) ;

string line = myStream.ReadLi ne();
while(line != null)
{
content += line;
line = myStream.ReadLi ne();
}
myStream.Close( );

fname.Delete();
}
It works except for fname.Delete();
I get an access denied on this. The file is not read-only if I check
properties in Explorer.

How can I fix this?

/Marre


Nov 16 '05 #9
Right click on the folder and choose properties. Go to "Security" Tab (4th
one). In the name list search for "evryone".
If you can't see everyone user in list, then click add button on right top.
In the users list appeared, search for everyone and click "Add" and then
"OK."
Now you can see everyone user in the security tab of properties window.
Click on "everyone" user" and see permissions box below it. Under the allow,
verify that Modify is selected. If no, then select it.

Hope that helps.

--
Dalvir Singh

"MA" <ne**@supremeli nk.se> wrote in message
news:2q******** ****@uni-berlin.de...
Well, my knowledge level of these permission-things are really low.

Where can I set this permission on my folder? When I rightclick on my folder and choose properties, I can´t set any permissions . Is there another way?

/Marre
"Dalvir Singh" <da**********@s ofthome.net> wrote in message
news:uj******** ******@TK2MSFTN GP09.phx.gbl...
Check the security setting of the folder. It should have "Modify"
permissions to everyone user.

Dalvir Singh
"MA" <ne**@supremeli nk.se> wrote in message
news:2q******** ****@uni-berlin.de...
Hi all!

I created a webservice that check folder for incoming and outgoing
files. If
a file exists in my inbox (incoming file) I read it and want to delete
it.
It looks like this:

foreach(FileInf o fname in folder.GetFiles ())
{
if(fname.Exists )
{
myStream = new StreamReader(fn ame.FullName,En coding.Default) ;

string line = myStream.ReadLi ne();
while(line != null)
{
content += line;
line = myStream.ReadLi ne();
}
myStream.Close( );

fname.Delete();
}
It works except for fname.Delete();
I get an access denied on this. The file is not read-only if I check
properties in Explorer.

How can I fix this?

/Marre



Nov 16 '05 #10

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

Similar topics

0
2935
by: Bill Burwell | last post by:
I am converting a VB6 WebClass application to VB.Net. Used the VB upgrade tool to do the conversion - and it left me a lot of little code things to do. Did those code things and got my app to compile. Did a few other code things to take advantage of .Net features not available in VB6. When I start the application on my PC I get the error shown below. It seems to me that the app initiation is failing before any app code is executed. My...
13
9538
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If Dir(strLDB) <> "" Then Kill (strLDB) where strLDB is the path to the ldb file. The client advises that the ldb doesn't lurk after the program closes. Any ideas?
5
483
by: Joe | last post by:
I'm getting the following error when trying to call a page on a secure server. I'm not doing any impersonations or file access of any kind. The page is using PayPal and I'm wondering if PayPal has something to do with this. We had to register an api certificate on the server using WinHttpCertCfg. Maybe this is doing something? Access denied to 'D:\WWWRoot\sslserver'. Failed to start monitoring file changes. Description: An unhandled...
3
7965
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images C:\Inetpub\wwwroot\RunReportASP is the directory of my virtual directory for my app. In it's properties I did check "Write" as a permission. What else do I need to do?
5
2114
by: Sandeep Singh Sekhon | last post by:
I am Developing a Web Application with ASP.NET 1.1 I have one project Folder which is virtual directory of IIS. In this directory, I have one Folder named Photos in which I used to Store Photos. On my Web Page, I have a button named delete which I used to delete photo in the folder. But when I click the button and apply the logic to delete the file, it raises an Exception that the access to the file is denied. I am using following code to...
1
3281
by: igotyourdotnet | last post by:
Ok, here is the issue: I have 2 web pages one does a file upload to a database and the other page does a FTP to a server, both pages use the c:\temp directory. The page that uploads to a database works fine, the page that FTP's the files returns me an error (Access denied filename.txt) Now the asp.net ID has full control of the c:\temp directory. The only difference in the 2 pages is that page 2 creates a text file writes data to it then...
5
1284
by: jawloc | last post by:
Hi I have a question that I hope someone can help me with. I have created a web page that allows a user to upload an image with a caption to my web server. Here is what happens when the user loads the page: 1 - A temporary folder is created with that user's username here is an example of the folder "c:\wwwroot\upload\tmp\username". 2 - The user uploads the file it gets saved in the temp folder.
0
3965
by: Andy | last post by:
Thanks Peter, I thought I'd give an update on this problem. My application had 2 assemblies that contained classed for the Data access and business logic layer. It was on one of them that I was getting the Access denied error. After checking different settings and googling I wasnt able to pinpoint the problem and as a temporary fix I decided to merge the two assemblies into one, my logic being no offending assembly no access denied...
7
1434
by: semomaniz | last post by:
I have a .NET page built with c#. This page creates a temporary report and then creates a pdf file. Then this file is sent to users via email. After the email is sent out i have written a code to delete the temporary file. My problem is i am getting a accessed denied exception. Exception Details: System.UnauthorizedAccessException: Access to the path 'c:\Inetpub\vhosts\***\***\****\10836.pdf' is denied. here is the code that checks for...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8989
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7512
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.