How does Read-Only affect a Directory?
Posted
by
ispiro
on Stack Overflow
See other posts from Stack Overflow
or by ispiro
Published on 2012-11-02T09:56:58Z
Indexed on
2012/11/02
11:00 UTC
Read the original article
Hit count: 296
I've found that I can write (say, copy a file into) a Read-Only directory. That is, a Directory with ...Attributes = FileAttributes.ReadOnly
.I can even change its name. The only thing I've found that can't be done is to delete it. Is that really the only thing that ReadOnly
prevents?
EDIT:
Here's the code: (The Directory is empty.)
(new DirectoryInfo(path)).Attributes = FileAttributes.ReadOnly;
Directory.Delete(path);
It throws an Access to the path 'c:\... is denied.
exception.
But after changing ReadOnly
to Normal
it works fine.
So what does a ReadOnly
prevent, and what doesn't it prevent?
© Stack Overflow or respective owner