Page 1 of 1

Folder Hider Hide a folder using VB6 Rate Topic: -----

#1 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Posted 03 January 2010 - 04:17 PM

Useful if you have to hide your DB from user or you want to lock some folder

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)



Is This A Good Question/Topic? 3
  • +

Replies To: Folder Hider

#2 WiFi COMPUTER SYSTEM  Icon User is offline

  • New D.I.C Head

Reputation: -8
  • View blog
  • Posts: 13
  • Joined: 05-October 12

Posted 06 October 2012 - 03:51 AM

Dim FS, F

Set FS = CreateObject("Scripting.FileSystemObject")

Set F = FS.GetFolder(%FOLDERPATH%) 'Replace %FOLDERPATH% with the folders path

F.Attributes = -1 ' -1 Makes it a system folder so its hidden from windows explorer(works for me on xp)

To unhide the folder simply put

Dim FS, F

Set FS = CreateObject("Scripting.FileSystemObject")

Set F = FS.GetFolder(%FOLDERPATH%) 'Replace %FOLDERPATH% with the folders path 

F.Attributes = 0 ' This returns the folder to normal in windows explorer

To hide files simply use this code

Dim FS, F

Set FS = CreateObject("Scripting.FileSystemObject")

Set F = FS.GetFile(%FILEPATH%) 'Replace %FILEPATH% with the files path

F.Attributes = -1 ' -1 Makes it a system file so its hidden from windows explorer(works for me on xp)

To unhide the file simply put

Dim FS, F

Set FS = CreateObject("Scripting.FileSystemObject")

Set F = FS.GetFile(%FILEPATH%) 'Replace %FILEPATH% with the files path

F.Attributes = 0 ' This retu

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1