1 '以下为FSO对象的使用示例(VB6.0) 2 Private myFSO As New FileSystemObject 3 Private myFile As File 4 Private myFolder As Folder 5 'myFolder.Attributes = Alias 6 'myFolder.Attributes = Archive 存档 7 'myFolder.Attributes = Compressed 压缩 8 'myFolder.Attributes = Directory 目录 9 'myFolder.Attributes = Hidden 10 'myFolder.Attributes = ReadOnly 11 'myFolder.Attributes = System 12 'myFolder.Attributes = Normal 13 'myFolder.Attributes = Volume 卷 14 Private Function ChangeProperty(ByVal strFileAndPath As String, nType As Long) As Boolean 15 On Error GoTo deleteError 16 ChangeProperty = False 17 If myFSO.FileExists(strFileAndPath) = True Then 18 Set myFile = myFSO.GetFile(strFileAndPath) 19 myFile.Attributes = nType 20 Set myFile = Nothing 21 ChangeProperty = True 22 End If 23 Exit Function 24 deleteError: 25 MsgBox Err.Description 26 Err.Clear 27 ChangeProperty = False 28 End Function 29 30 Private Function ChangeFolder(ByVal strFileAndPath As String, nType As Long) As Boolean 31 On Error GoTo deleteError 32 ChangeFolder = False 33 If myFSO.FolderExists(strFileAndPath) = True Then 34 Set myFolder = myFSO.GetFolder(strFileAndPath) 35 myFolder.Attributes = nType 36 Set myFolder = Nothing 37 ChangeFolder = True 38 End If 39 Exit Function 40 deleteError: 41 MsgBox Err.Description 42 Err.Clear 43 ChangeFolder = False 44 End Function