⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileinfo.cls

📁 这是一个在vb下实现的各种加密程序,可以实现一般的文本加密和文件加密,但是很多算法都是已经被人破解过的.
💻 CLS
📖 第 1 页 / 共 2 页
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 1  'Persistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "FileInfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'    CopyRight (c) 2005 Kelly Ethridge
'
'    This file is part of VBCorLib.
'
'    VBCorLib is free software; you can redistribute it and/or modify
'    it under the terms of the GNU Library General Public License as published by
'    the Free Software Foundation; either version 2.1 of the License, or
'    (at your option) any later version.
'
'    VBCorLib is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU Library General Public License for more details.
'
'    You should have received a copy of the GNU Library General Public License
'    along with Foobar; if not, write to the Free Software
'    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
'
'    Module: FileInfo
'

''
' Provides methods for manipulating, setting and retrieving information for the specified file.
'
' @remarks The existence of the file is not verified until an action that requires
' accessing the file.
' <pre>
' Dim info As FileInfo
' Set info = NewFileInfo("c:\myfile.txt")
' Debug.Print info.Length
' </pre>
'
' @see Constructors
'
Option Explicit
Implements IObject
Implements FileSystemInfo

Private mFileName           As String
Private mOriginalFileName   As String
Private mIsDirty            As Boolean
Private mFileAttributes     As FileAttributes
Private mFileSize           As Currency
Private mCreationTime       As cDateTime
Private mLastAccessTime     As cDateTime
Private mLastWriteTime      As cDateTime



''
' Returns the attributes for the file (ReadOnly, Hidden, ...)
'
' @return The attributes of the file.
' @remarks The attributes are represented as bits. Each attributes has a specific bit.
' To test if a specific attribute exists, the attributes need to be ANDed with
' the individual attribute bits.
'
Public Property Get Attributes() As FileAttributes
    If mIsDirty Then Refresh
    Attributes = mFileAttributes
End Property

''
' Sets the attributes for the file (ReadOnly, Hiddin, ...)
'
' @param RHS The attributes to set the file to.
' @remarks All attributes are set at once. In order to modify a single attribute,
' the remaining attribute settings need to be included with the modified attribute.
'
Public Property Let Attributes(ByVal RHS As FileAttributes)
    Call File.SetAttributes(mFileName, RHS)
    Call MarkDirty
End Property

''
' Returns the creation time as a cDateTime object.
'
' @return The creation time of the file.
'
Public Property Get CreationTime() As Variant
    If mIsDirty Then Refresh
    Set CreationTime = mCreationTime
End Property

''
' Sets the creation time of the file.
'
' @param RHS A Date or cDateTime object of the new time.
'
Public Property Let CreationTime(ByVal RHS As Variant)
    Set Me.CreationTime = cDateTime.GetcDateTime(RHS)
End Property

''
' Sets the creation time of the file.
'
' @param RHS A Date or cDateTime object of the new time.
'
Public Property Set CreationTime(ByVal RHS As Variant)
    If Not TypeOf RHS Is cDateTime Then _
        Throw Cor.NewArgumentException(Environment.GetResourceString(Argument_DateRequired), "CreationTime")

    Set mCreationTime = RHS
    File.SetCreationTime mFileName, mCreationTime
    Call MarkDirty
End Property

''
' Returns the creation time as a UTC time.
'
' @return The creation time of the file in UTC time.
'
Public Property Get CreationTimeUtc() As Variant
    If mIsDirty Then Refresh
    Set CreationTimeUtc = mCreationTime.ToUniversalTime
End Property

''
' Sets the creation time of the file in UTC time.
'
' @param RHS A Date or cDateTime object of the new time.
'
Public Property Let CreationTimeUtc(ByVal RHS As Variant)
    Set Me.CreationTimeUtc = cDateTime.GetcDateTime(RHS)
End Property

''
' Sets the creation time of the file in UTC time.
'
' @param RHS A Date or cDateTime object of the new time.
'
Public Property Set CreationTimeUtc(ByVal RHS As Variant)
    If Not TypeOf RHS Is cDateTime Then _
        Throw Cor.NewArgumentException(Environment.GetResourceString(Argument_DateRequired), "CreationTimeUtc")

    Call File.SetCreationTimeUtc(mFileName, RHS)
    Call MarkDirty
End Property

''
' Returns the last time the file was accessed.
'
' @return A cDateTime object of the last access time.
'
Public Property Get LastAccessTime() As Variant
    If mIsDirty Then Refresh
    Set LastAccessTime = mLastAccessTime
End Property

''
' Sets the time the file was last accessed.
'
' @param RHS A Date or cDateTime object of the new time.
'
Public Property Let LastAccessTime(ByVal RHS As Variant)
    Set Me.LastAccessTime = cDateTime.GetcDateTime(RHS)
End Property

''
' Sets the time the file was last accessed.
'
' @param RHS A Date or cDateTime object of the new time.
'
Public Property Set LastAccessTime(ByVal RHS As Variant)
    If Not TypeOf RHS Is cDateTime Then _
        Throw Cor.NewArgumentException(Environment.GetResourceString(Argument_DateRequired), "LastAccessTime")
        
    Set mLastAccessTime = RHS
    Call File.SetLastAccessTime(mFileName, mLastAccessTime)
    Call MarkDirty
End Property

''
' Returns the time the file was last accessed in UTC time.
'
' @return A cDateTime object of the last accessed UTC time.
'
Public Property Get LastAccessTimeUtc() As Variant
    If mIsDirty Then Refresh
    Set LastAccessTimeUtc = mLastAccessTime.ToUniversalTime
End Property

''
' Sets the time the file was last accessed in UTC time.
'
' @param RHS A Date or cDateTime object of the new UTC time.
'
Public Property Let LastAccessTimeUtc(ByVal RHS As Variant)
    Set Me.LastAccessTimeUtc = cDateTime.GetcDateTime(RHS)
End Property

''
' Sets the time the file was last accessed in UTC time.
'
' @param RHS A Date or cDateTime object of the new UTC time.

Public Property Set LastAccessTimeUtc(ByVal RHS As Variant)
    If Not TypeOf RHS Is cDateTime Then _
        Throw Cor.NewArgumentException(Environment.GetResourceString(Argument_DateRequired), "LastAccessTimeUtc")
    
    Call File.SetLastAccessTimeUtc(mFileName, RHS)
    Call MarkDirty
End Property

''
' Returns the last time the file was written to.
'
' @return A cDateTime object of the last time the file was written to.
'
Public Property Get LastWriteTime() As Variant
    If mIsDirty Then Refresh
    Set LastWriteTime = mLastWriteTime
End Property

''
' Sets the last time the file was written to.
'
' @param RHS A Date or cDateTime object of the new time.
'
Public Property Let LastWriteTime(ByVal RHS As Variant)
    Set Me.LastAccessTime = cDateTime.GetcDateTime(RHS)
End Property

''
' Sets the last time the file was written to.
'
' @param RHS A Date or cDateTime object of the new time.
'
Public Property Set LastWriteTime(ByVal RHS As Variant)
    If Not TypeOf RHS Is cDateTime Then _
        Throw Cor.NewArgumentException(Environment.GetResourceString(Argument_DateRequired), "LastWriteTime")
    
    Set mLastWriteTime = RHS
    Call File.SetLastWriteTime(mFileName, mLastWriteTime)
    Call MarkDirty
End Property

''
' Returns the last time the file was accessed in UTC time.
'
' @return A cDateTime object of the last time the file was written to.
'
Public Property Get LastWriteTimeUtc() As Variant
    If mIsDirty Then Refresh
    Set LastWriteTimeUtc = mLastWriteTime.ToUniversalTime
End Property

''
' Sets the last the time file was written to in UTC time.
'
' @param RHS A Date or cDateTime object of the new time.
'
Public Property Let LastWriteTimeUtc(ByVal RHS As Variant)
    Set Me.LastWriteTimeUtc = cDateTime.GetcDateTime(RHS)
End Property

''
' Sets the last time the file was written to in UTC time.
'
' @param RHS A Date or cDateTime object of the new time.
'
Public Property Set LastWriteTimeUtc(ByVal RHS As Variant)
    If Not TypeOf RHS Is cDateTime Then _
        Throw Cor.NewArgumentException(Environment.GetResourceString(Argument_DateRequired), "LastAccessTimeUtc")
    
    Call File.SetLastWriteTimeUtc(mFileName, RHS)
    Call MarkDirty
End Property

''
' Returns a DirectoryInfo object of the directory portion of the file.
'
' @return A DirectoryInfo object of the directory.
' @remarks This does not verify the file exists, or the directory.
'
Public Property Get Directory() As DirectoryInfo
    Set Directory = Cor.NewDirectoryInfo(DirectoryName)
End Property

''
' Returns the directory portion of the filename.
'
' @return The directory portion of the filename.
' @remarks This does not very the existence of the file.
'
Public Property Get DirectoryName() As String
    DirectoryName = Path.GetDirectoryName(mFileName)
End Property

''
' Indicates if the file exists on disk.
'
' @return An indication of the existence of the file.
'
Public Property Get Exists() As Boolean
    Exists = File.Exists(mFileName)
End Property

''
' Returns the extension portion of the filename.
'
' @return The extension portion of the filename.
'
Public Property Get Extension() As String
    Extension = Path.GetExtension(mFileName)
End Property

''
' Returns a full path to the file, including the filename.
'
' @return A full path to the file.
' @remarks If not root directory portion is found in the
' filename, then the currenct directory is used.
'
Public Property Get FullName() As String
    FullName = Path.GetFullPath(mFileName)
End Property

''
' Returns the size of the file in bytes.
'
' @return The size of the file.
' @remarks A Currency datatype is used to allow file sizes greater than 2gig.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -