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
  • 相关阅读:
    Git 游离态的一次问题解决
    idea每次新建项目的默认路径
    springboot 整合 freemarker
    Linux 学习网站
    springtask 基本使用和 cron 表达式
    volatile 关键字 和 i++ 原子性
    python 自动补全
    nagios维护之常见问题
    nagios维护之添加监控
    windows下python文件与文件夹操作
  • 原文地址:https://www.cnblogs.com/lhghroom/p/7668872.html
Copyright © 2011-2022 走看看