首页 > 其他 > 详细

VB改变文件及文件夹属性的函数

时间:2017-10-14 23:03:36      阅读:332      评论:0      收藏:0      [点我收藏+]
 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

 

VB改变文件及文件夹属性的函数

原文:http://www.cnblogs.com/lhghroom/p/7668872.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!