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

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(FileInfo fname in folder.GetFiles())
{
if(fname.Exists)
{
myStream = new StreamReader(fname.FullName,Encoding.Default);

string line = myStream.ReadLine();
while(line != null)
{
content += line;
line = myStream.ReadLine();
}
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 2149
Hi,

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

Go to sysinternals.com 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**@supremelink.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(FileInfo fname in folder.GetFiles())
{
if(fname.Exists)
{
myStream = new StreamReader(fname.FullName,Encoding.Default);

string line = myStream.ReadLine();
while(line != null)
{
content += line;
line = myStream.ReadLine();
}
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.machin AT dot.state.fl.us> wrote
in message news:Oi**************@TK2MSFTNGP12.phx.gbl...
Hi,

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

Go to sysinternals.com 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**@supremelink.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(FileInfo fname in folder.GetFiles())
{
if(fname.Exists)
{
myStream = new StreamReader(fname.FullName,Encoding.Default);

string line = myStream.ReadLine();
while(line != null)
{
content += line;
line = myStream.ReadLine();
}
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 FileSystemWatcher it may generate more than one event for a
"change" depending of what events you are using.

Go to sysinternals.com 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**@supremelink.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(FileInfo fname in folder.GetFiles())
{
if(fname.Exists)
{
myStream = new StreamReader(fname.FullName,Encoding.Default);

string line = myStream.ReadLine();
while(line != null)
{
content += line;
line = myStream.ReadLine();
}
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.machin AT dot.state.fl.us> wrote
in message news:Oi**************@TK2MSFTNGP12.phx.gbl...
Hi,

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

Go to sysinternals.com 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**@supremelink.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(FileInfo fname in folder.GetFiles())
{
if(fname.Exists)
{
myStream = new StreamReader(fname.FullName,Encoding.Default);

string line = myStream.ReadLine();
while(line != null)
{
content += line;
line = myStream.ReadLine();
}
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**@supremelink.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(FileInfo fname in folder.GetFiles())
{
if(fname.Exists)
{
myStream = new StreamReader(fname.FullName,Encoding.Default);

string line = myStream.ReadLine();
while(line != null)
{
content += line;
line = myStream.ReadLine();
}
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**@supremelink.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(FileInfo fname in folder.GetFiles())
{
if(fname.Exists)
{
myStream = new StreamReader(fname.FullName,Encoding.Default);

string line = myStream.ReadLine();
while(line != null)
{
content += line;
line = myStream.ReadLine();
}
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**********@softhome.net> wrote in message
news:uj**************@TK2MSFTNGP09.phx.gbl...
Check the security setting of the folder. It should have "Modify"
permissions to everyone user.

Dalvir Singh
"MA" <ne**@supremelink.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(FileInfo fname in folder.GetFiles())
{
if(fname.Exists)
{
myStream = new StreamReader(fname.FullName,Encoding.Default);

string line = myStream.ReadLine();
while(line != null)
{
content += line;
line = myStream.ReadLine();
}
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**********@softhome.net> wrote in message
news:uj**************@TK2MSFTNGP09.phx.gbl...
Check the security setting of the folder. It should have "Modify"
permissions to everyone user.

Dalvir Singh
"MA" <ne**@supremelink.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(FileInfo fname in folder.GetFiles())
{
if(fname.Exists)
{
myStream = new StreamReader(fname.FullName,Encoding.Default);

string line = myStream.ReadLine();
while(line != null)
{
content += line;
line = myStream.ReadLine();
}
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**@supremelink.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**********@softhome.net> wrote in message
news:uj**************@TK2MSFTNGP09.phx.gbl...
Check the security setting of the folder. It should have "Modify"
permissions to everyone user.

Dalvir Singh
"MA" <ne**@supremelink.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(FileInfo fname in folder.GetFiles())
{
if(fname.Exists)
{
myStream = new StreamReader(fname.FullName,Encoding.Default);

string line = myStream.ReadLine();
while(line != null)
{
content += line;
line = myStream.ReadLine();
}
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
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**@supremelink.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**********@softhome.net> wrote in message
news:uj**************@TK2MSFTNGP09.phx.gbl...
Check the security setting of the folder. It should have "Modify"
permissions to everyone user.

Dalvir Singh
"MA" <ne**@supremelink.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(FileInfo fname in folder.GetFiles())
{
if(fname.Exists)
{
myStream = new StreamReader(fname.FullName,Encoding.Default);

string line = myStream.ReadLine();
while(line != null)
{
content += line;
line = myStream.ReadLine();
}
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 #11
MA
Hmm....I do not have this Tab....and Iīm logged in as administrator......

/Marre
"Dalvir Singh" <da**********@softhome.net> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
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**@supremelink.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**********@softhome.net> wrote in message
news:uj**************@TK2MSFTNGP09.phx.gbl...
> Check the security setting of the folder. It should have "Modify"
> permissions to everyone user.
>
> Dalvir Singh
>
>
> "MA" <ne**@supremelink.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(FileInfo fname in folder.GetFiles())
>> {
>> if(fname.Exists)
>> {
>> myStream = new StreamReader(fname.FullName,Encoding.Default);
>>
>> string line = myStream.ReadLine();
>> while(line != null)
>> {
>> content += line;
>> line = myStream.ReadLine();
>> }
>> 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 #12
MA
Hmm....I do not have this Tab....and Iīm logged in as administrator......

/Marre
"Dalvir Singh" <da**********@softhome.net> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
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**@supremelink.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**********@softhome.net> wrote in message
news:uj**************@TK2MSFTNGP09.phx.gbl...
> Check the security setting of the folder. It should have "Modify"
> permissions to everyone user.
>
> Dalvir Singh
>
>
> "MA" <ne**@supremelink.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(FileInfo fname in folder.GetFiles())
>> {
>> if(fname.Exists)
>> {
>> myStream = new StreamReader(fname.FullName,Encoding.Default);
>>
>> string line = myStream.ReadLine();
>> while(line != null)
>> {
>> content += line;
>> line = myStream.ReadLine();
>> }
>> 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 #13

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

Similar topics

0
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...
13
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...
5
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...
3
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 ...
5
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....
1
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...
5
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...
0
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...
7
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...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.