By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,579 Members | 1,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,579 IT Pros & Developers. It's quick & easy.

Setting read-only property for a directory.

P: n/a
I can't believe how hard it is to find information on this. Doing it for
files is simple but I need to do it for directories. All I want to do is
create a directory structure and set the read-only attribute on a few of the
directories created in the structure. Security and permissions won't be an
issue since the user running the app will be an admin logged in as the admin
of the network. Anyone have a starting point for information on doing this?

Thanks a lot!
Regards,
-Tony
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Tony" <no**@nowhere.com> schrieb:
I can't believe how hard it is to find information on this. Doing it for
files is simple but I need to do it for directories. All I want to do is
create a directory structure and set the read-only attribute on a few of
the directories created in the structure.


(1) VB.NET's 'SetAttr' and 'GetAttr' functions:

\\\
SetAttr( _
"C:\foo", _
GetAttr("C:\foo") Or FileAttribute.ReadOnly _
)
///

(2) 'DirectoryInfo' class:

\\\
Imports System.IO
..
..
..
Dim f As New DirectoryInfo("C:\foo")
f.Attributes = f.Attributes Or FileAttributes.ReadOnly
///

(3) 'File' class:

\\\
Imports System.IO
..
..
..
File.SetAttributes( _
"C:\foo", _
File.GetAttributes("C:\foo") Or FileAttributes.ReadOnly _
)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.