Access to Path Denied

M

Martin

I'm trying to write a simple app to verify that my data is being backed up
using a mirroring tool (and, perhaps, to make my own tool that does
specifically what I need)...


DirectoryInfo di = new DirectoryInfo(@"C:\users\schmidm");

FileInfo[] fiArr = di.GetFiles("*.*",
SearchOption.AllDirectories);

Results in:

Access to the path 'C:\users\schmidm\Templates' is denied.

Thoughts? What other headaches will I run into with the wonderful world of
windows security?

TIA
 
R

raylopez99

Access to the path 'C:\users\schmidm\Templates' is denied.

Thoughts?  What other headaches will I run into with the wonderful world of
windows security?

Seems like this is a network question, which, like you say, involves
security. For example from my User account, if I try and write a file
to the Administrator account in XP/Vista, it will fail, as I don't
have permission.

This comes up even with standalone database programming--when I was
playing around with SQL Server a while ago, this would pop up. So I
ended up, for programming purposes, storing everything on the local
subdirectory the program was being executed in, but, like you say, for
your mirroring program that won't do.

In C# there is a class to fool with the stream permissions, you might
want to Google this assuming no more help here, though I think that
class deals with encoding a file so it cannot be read without the
proper permission, rather than what you seem to want (writing to a
directory).

RL
 
A

Alex Meleta

Hi Martin,

... and .NET Security, http://msdn.microsoft.com/en-us/library/aa720329(VS.71).aspx

Anyway, it's a "known bug" to failure passing through entire folder tree
using DirectoryInfo and if at least one folder is protected. Use iterating
through folders with checking instead, such as: http://forums.msdn.microsoft.com/en-US/netfxbcl/thread/a88ab09f-c6e8-453c-92cc-3544e6cd1ae1/

Regards, Alex Meleta
mailto:[email protected]; blog:devkids.blogspot.com
AllDirectories
Thoughts? What other headaches will I run into with the wonderful world
of windows security?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top