Directory Always Read Only

J

Jim

I have the following piece of code:

Directory.CreateDirectory(myDir);
DirectoryInfo lDir = new DirectoryInfo(myDir);
lDir.Attributes = FileAttributes.Normal;

When this code runs, my directory is created fine, but my directory is
always read only. At first I thought it was something with using
DirectoryInfo. However, I also ran the following line of code:

Directory.CreateDirectory(myDir);

Immediately after running this line of code, my directory was created, and
then I went and manually tried to change the attributes of the directory so
that it was not read only. Even after I tried to set it manually, it would
always be read only. I never received back an error after I pushed OK on
the directory properties after unchecking read only, but every time I go
back to the properties of the folder it is always read only?

This is running on Windows Vista. Any ideas why?

Thanks,
-- Jim
 
J

Jim

Well, after doing more reading, it doesn't look like this is just me. This
guy's site:
http://www.followsteph.com/2007/06/17/windows-vista-read-only/
has several references to threads in which people cannot change the
read-only property of a folder. My Google skills are failing me to find the
answer too. Does anybody know why I can't change the read-only property of
a folder on my Vista machine (it's a temporary folder I make in my Debug
directory during debugging)? More importantly, does anybody know how I can
fix this via normal administration and via code (some example code would be
cool too)?

My installation of Vista is just the normal RTM Vista CD from my MSDN
subscription. I setup my account as an administrator, and that's what I'm
logging in with.

Thanks again,
-- Jim
 
J

Jim

OK,

Since this seemed like more of a Vista question, I posted this to the Vista
newsgroup. Here's the response I got there:
-----------
The read-only checkbox is irrelevant for folders. Notice it is filled in
with a square as opposed to a check, which indicates that it is NOT
checked but rather in an 'indeterminate' state.

If you are having folder access issues, it is because of the security
permissions on the folder.

The checkbox is there only so that you can easily set or clear the
read-only attribute on the files inside of that folder.
-----------

Well, I wasn't aware that there was an 'indeterminate' state. Anyway, I
think the ball is back in the .NET court. My main problem is that when I
try to call Directory.Delete(myDir, true); on the directory, I get back an
IOException directory not empty error. All of the files in my directory are
deleted, but the directory itself is not deleted. Some thread somewhere
suggested that it was because the folder was read-only. I'm not sure if
this 'indeterminate' state is causing this IOException.

Therefore, does anybody have any idea why I can't delete this directory
entirely? All of the files in it are deleted, I just don't understand why
the debugger gets mad when it tries to delete the actual directory.

-- Jim
 
S

sa

A directory is always shown as readonly in windows. This is nothing to
do with dotnet. This is because a directory dont have body so there is
nothing like editing a directory's content.

________________________
(e-mail address removed)
http://www.openwinforms.com/
OpenWinForms - open source windows forms and controls
 
J

Jim

OK,

Maybe it has nothing to do with anything read-only. That was just my
initial thought. My main problem is that when I try to call
Directory.Delete(myDir, true); on the directory, I get back an IOException
directory not empty error. All of the files are deleted fine in the
directory, but the directory itself is not deleted, and I keep getting this
error.

Any other ideas?
 

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