BASit Bulbulia BASit Bulbulia - 10 months ago 66 Question

How can I completely hide a directory in .net vb

I can do this using command prompt attrib +s +h c:\stock and the directory will be totally hidden from file explorer.

If however I do it in code like below it will show up the directory if view hidden files is ticked. Can someone tell me how in code i could achieve a total hide of a directory like what the attrib command does.

Below is my code :-

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

IO.File.SetAttributes("c:\stock", IO.FileAttributes.Hidden)

End Sub
End Class

Answer Source

The equivalent VB.NET of attrib +s +h is

IO.File.SetAttributes("c:\stock", IO.FileAttributes.Hidden  Or 

(+s is System attribute)

but you have not really made your directory totally hidden because the visualization of System files and directory could be enabled as you enable the visualization of Hidden files and directory.

Make a Super Hidden Folder in Windows Without any Extra Software