.NETGURU
deleting file - access denied
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.csharp.

Post a new message to this list...

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

Reply to this message...
 
    
Ignacio Machin \( .NET/ C# MVP \)
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" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
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:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Dalvir Singh
Check the security setting of the folder. It should have "Modify"
permissions to everyone user.

Dalvir Singh

"MA" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
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" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Dalvir Singh
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" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
MA
Hmm....I do not have this Tab....and I“m logged in as administrator......

/Marre
"Dalvir Singh" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.IO.FileInfo
System.IO.FileSystemWatcher
System.IO.StreamReader
System.Text.Encoding




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification