Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
i write a program with visual basic 6.0

that the hide all folder at program path(app.path)

but only hide folders that contain file and don't hide any file

now , i want know that what be hide all of file and folder in program path????

the source:
Dim fso As New FileSystemObject

Public Sub allfilelock(path As String)
Dim f As Folder, fc As Folders, f1 As Folder
Dim fil As Files
Set f = fso.GetFolder(path)
Set fc = f.SubFolders
If fc.Count = 0 Then
Exit Sub
End If
For Each f1 In fc
        Set fil = f1.Files
        If fil.Count <> 0 Then
       SetAttr f1.path, vbHidden  + vbSystem
       
        End If

allfilelock (f1.path)
Next
End Sub

Public Sub allfileshow(path As String)
Dim f As Folder, fc As Folders, f1 As Folder
Dim fil As Files
Set f = fso.GetFolder(path)
Set fc = f.SubFolders
If fc.Count = 0 Then
Exit Sub
End If
For Each f1 In fc
        Set fil = f1.Files
        If fil.Count <> 0 Then
     SetAttr f1.path, vbArchive
        End If

allfilelock (f1.path)
Next
End Sub

Private Sub Form_Load()
On Error GoTo errhandler
errhandler:
Select Case Err.Number
Case 53:
MsgBox (" File For Hidden Not Found ")
Exit Sub
End Select

End Sub

Private Sub LHCommand1_Click()
allfilelock App.path
End Sub

Private Sub LHCommand2_Click()
allfileshow App.path
End Sub
Posted

1 solution

This won't work, anyone can set up Windows to show hidden files. Why are you using VB6 ? Why not learn a real, modern, supported language ? However, files CAN be marked as hidden, so I guess you're not doing it right.
 
Share this answer
 
Comments
[no name] 1-Sep-11 15:02pm    
You mean .NET? Please suggest some language.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900