How can I creat hide directory?

G

Guest

Hi EveryBody:

I used vb.Net to creat the foolwoing directory:

Directory.CreateDirectory("C:\windows98\windowsdll\win32app\direction")

but my question is how can I used vb.net to hide the directory?

any help will be appreciated

regard's

Husam
 
J

JR

Dim diMyDir As New DirectoryInfo(Your DirName)

diMyDir.Attributes = FileAttributes.Hidden
 
H

Herfried K. Wagner [MVP]

Husam said:
I used vb.Net to creat the foolwoing directory:

Directory.CreateDirectory("C:\windows98\windowsdll\win32app\direction")

but my question is how can I used vb.net to hide the directory?

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

\\\
SetAttr( _
"C:\foo", _
GetAttr("C:\foo") And Not FileAttribute.Hidden _
)
///

(2) 'DirectoryInfo' class:

\\\
Imports System.IO
..
..
..
Dim f As New FileInfo("C:\foo")
f.Attributes = f.Attributes And Not FileAttributes.Hidden
///

(3) 'File' class:

\\\

Imports System.IO
..
..
..
File.SetAttributes( _
"C:\foo", _
File.GetAttributes("C:\foo") And Not FileAttributes.Hidden _
)
///
 
J

Jay B. Harlow [MVP - Outlook]

Husam,
As the others suggest, you can set the DirectoryInfo.Attributes to
FileAttributes.Hidden.

Rather then create a folder in what appears to be the Windows System
Directory, I would seriously suggest you consider using the "Program Files"
folder instead.

Something like:

Dim directoryPath As String
directoryPath =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
"windowsdll\win32app\direction")
Directory.CreateDirectory(directoryPath)
Dim info As New DirectoryInfo(directoryPath)
info.Attributes = FileAttributes.Hidden

Note Environment.SpecialFolder has a number of values that represent other
special folders such as the windows installation directory...

Hope this helps
Jay
 

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

Top