Using:
FileSystemObject
Require:
Microsoft Scripting Runtime
or
C:\WINDOWS\System32\scrrun.dll
so using attributes of the folder we hide it and by giving it a different name from the one he have it will not be even able to access it from Command Prompt. So here is the code for hiding
Private Sub Command1_Click() Dim FS As New FileSystemObject Dim F Dim strPath As String strPath = "E:\TestFolder" Name strPath As strPath & "A" Set F = FS.GetFolder(strPath & "A") f.Attributes = -1 End Sub
so lets explain to variable F we send the folder we want to hide. by changing his name it will not be able to access it with command prompt and by setting its attributes to "-1" we make it a system folder so its hidden from windows explorer(works for me on xp, on vista need to refresh the folder but it works).
So here is the code to bring it back
Private Sub Command2_Click() Dim fs As New FileSystemObject Dim f Dim strPath As String strPath = "E:\TestFolder" Set f = fs.GetFolder(strPath & "A") f.Attributes = 0 Name strPath & "A" As strPath End Sub
it is the reverse of the first code by making it 0 we return it to normal and rename it to original name
so here it is
Attached File(s)
-
Folder_Hider_VB6.zip (5.42K)
Number of downloads: 1711





MultiQuote





|