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
  • 相关阅读:
    Win10导出查看删除已安装的证书
    Tomcat配置https访问
    SpringBoot启用https
    使用OpenSSL证书操作详解
    sed命令常用用法
    Jenkins安装第一个插件和通过离线安装包进行安装
    CentOS设置主机名称
    Jenkins使用过程中遇到的问题
    Visual Studio 最新插件
    文章去格式
  • 原文地址:https://www.cnblogs.com/lhghroom/p/7668872.html
Copyright © 2011-2022 走看看