zoukankan      html  css  js  c++  java
  • VB改变文件及文件夹属性的函数

     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
    欢迎大家添加我为好友: QQ: 578652607
  • 相关阅读:
    SQLite学习第02天:数据类型
    SQLite学习第01天:参考资料
    利用OllyDebug查看程序调用的dll模块
    Qt文件信息获取之QFileInfo
    Qt标准对话框之QColorDialog
    Windows平台下Qt开发环境的搭建
    何时使用引用参数(转)
    OpenCV2学习笔记01:Linux下OpenCV开发环境的搭建
    node实现缓存
    node进阶之用流实现上传文件
  • 原文地址:https://www.cnblogs.com/lhghroom/p/7668872.html
Copyright © 2011-2022 走看看