473,407 Members | 2,629 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,407 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 11801
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: o'seally | last post by:
solaris/linux admins/rookie_developers that battle with this error are probably all frustrated when it happens. i bet you're also somehow frustrated by this seemingly unsolvable error :-) ...take...
2
by: 73blazer | last post by:
Hello, I'm writing some C++ code, and I need to be able to find the number of files in a given directory. Is it possible under AIX4.3.3 with C++ 3.6.4? I cannot seem to locate anything of this...
6
by: Hemant Shah | last post by:
Folks, I need to move HOME directory of an instance to another directory. What is the best way of doing it? Is changing password file enough? or dies DB2 store this info in it's own config? ...
6
by: gl | last post by:
I'm trying to delete a directory that contains readonly files. Is there any easy way to do this? I get a System.UnauthorizedAccessException when a read only file is encountered. Is there a way to...
3
by: James Coleman | last post by:
Hello, The following error is appearing when attempting to create a directory using the availale system.io methods: System.IO.DirectoryNotFoundException: Could not find a part of the path...
4
by: Jerry | last post by:
I'm having just a bit of trouble wrapping my brain around the task of working with folders that are above the site's root folder. I let users upload photos (.jpg/.gif files) which can...
5
by: Verane | last post by:
Hi, I have read the thread named "Could not copy temporary files to the output directory" on this newsgroup. And I have the same symptoms on my machine. But I didn't find any solution suitable for...
1
by: Frank F | last post by:
Hi, I want to read user information from the microsoft windows 2003 server. In the windows server 2003, i've create a domain, called "wissenskolleg". I've assigned a password to it. Now, i...
3
by: Chris Mellon | last post by:
This appears to be a change in behavior from Python 2.4 to Python 2.5, which I can't find documented anywhere. It may be windows only, or related to Windows behavior. In 2.4, the current...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.