• 我最近写的通用安全文件夹删除函数,跟大家分享


    鉴于删除文件夹操作比较特殊,需要安全一点,所以封装成一通用安全文件夹删除函数,跟大家分享:

        Public Shared Function DeleteFolder(ByVal strDirectory As String) As Boolean
            '名称:DeleteFolder
            '功能:安全删除文件夹
            '作者:chs
            '创建:2004/2/5
            '修改:2004/2/5
            '参数::
            '      :
            '返回:成功,True,反之,False
            '说明:

            Dim o_blnRet As Boolean = False

            Try
                Dim o_objDir As New DirectoryInfo(strDirectory)
                Dim o_objFileInfo() As FileInfo = o_objDir.GetFiles()
                Dim o_intItems As Integer

                For o_intItems = 0 To o_objFileInfo.Length - 1
                    With o_objFileInfo(o_intItems)
                        '把文件的属性该成普通,让其能正常删除
                        .Attributes = FileAttributes.Normal

                        '删除文件
                        .Delete()
                    End With
                Next

                o_objDir.Delete()

                o_objFileInfo = Nothing
                o_objDir = Nothing

                o_blnRet = True
            Catch ex As Exception
                o_blnRet = False
            End Try

            Return o_blnRet
        End Function

  • 相关阅读:
    wim文件位置
    用DISM++来管理wim当中的驱动
    交易所基金代码段
    systemd配置nginx
    MACD公式
    nginx配置
    linux的tmfps
    nohup&
    geth
    RGB
  • 原文地址:https://www.cnblogs.com/unruledboy/p/10471.html
Copyright © 2020-2023  润新知