Setting read-only property for a directory.

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

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
 
Tony said:
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 _
)
///
 

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

Back
Top