'以下为FSO对象的使用示例(VB6.0)
Private myFSO As New FileSystemObject
Private myFile As File
Private myFolder As Folder
'myFolder.Attributes = Alias
'myFolder.Attributes = Archive 存档
'myFolder.Attributes = Compressed 压缩
'myFolder.Attributes = Directory 目录
'myFolder.Attributes = Hidden
'myFolder.Attributes = ReadOnly
'myFolder.Attributes = System
'myFolder.Attributes = Normal
'myFolder.Attributes = Volume 卷
Private Function ChangeProperty(ByVal strFileAndPath As String, nType As Long) As Boolean
On Error GoTo deleteError
ChangeProperty = False
If myFSO.FileExists(strFileAndPath) = True Then
Set myFile = myFSO.GetFile(strFileAndPath)
myFile.Attributes = nType
Set myFile = Nothing
ChangeProperty = True
End If
Exit Function
deleteError:
MsgBox Err.Description
Err.Clear
ChangeProperty = False
End Function Private Function ChangeFolder(ByVal strFileAndPath As String, nType As Long) As Boolean
On Error GoTo deleteError
ChangeFolder = False
If myFSO.FolderExists(strFileAndPath) = True Then
Set myFolder = myFSO.GetFolder(strFileAndPath)
myFolder.Attributes = nType
Set myFolder = Nothing
ChangeFolder = True
End If
Exit Function
deleteError:
MsgBox Err.Description
Err.Clear
ChangeFolder = False
End Function