472,142 Members | 1,316 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

Directory Always Read Only

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
Jul 18 '07 #1
4 11606
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/1...sta-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

"Jim" <ji********@ngc.comwrote in message
news:15***************************@FUSE.NET...
>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


Jul 19 '07 #2
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
"Jim" <ji********@ngc.comwrote in message
news:1d***************************@FUSE.NET...
Well, after doing more reading, it doesn't look like this is just me.
This guy's site:
http://www.followsteph.com/2007/06/1...sta-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

"Jim" <ji********@ngc.comwrote in message
news:15***************************@FUSE.NET...
>>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



Jul 19 '07 #3
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.

________________________
sa@openwinforms.com
http://www.openwinforms.com/
OpenWinForms - open source windows forms and controls

Jul 19 '07 #4
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?

<sa@openwinforms.comwrote in message
news:11*********************@n60g2000hse.googlegro ups.com...
>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.

________________________
sa@openwinforms.com
http://www.openwinforms.com/
OpenWinForms - open source windows forms and controls

Jul 19 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by 73blazer | last post: by
6 posts views Thread by Hemant Shah | last post: by
3 posts views Thread by James Coleman | last post: by
3 posts views Thread by Chris Mellon | last post: by
reply views Thread by leo001 | last post: by

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.