Namespace System Namespace IO Class FileInfo Inherits FileSystemInfo Public Sub FileInfo(path As String) OriginalPath = path FullPath = Path.GetFullPath(path) End Sub Sub ~FileInfo() End Sub '---------------------------------------------------------------- ' パブリック プロパティ '---------------------------------------------------------------- Function Directory() As DirectoryInfo Return New DirectoryInfo(Path.GetDirectoryName(FullPath)) End Function Function DirectoryName() As String Return Path.GetDirectoryName(FullPath) End Function Function IsReadOnly() As Boolean If (Attributes and FileAttributes.ReadOnly) = FileAttributes.ReadOnly Then Return True Else Return False End If End Function Function Length() As QWord Dim hFile = CreateFile(ToTCStr(FullPath), GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) If hFile = INVALID_HANDLE_VALUE Then Throw New IOException("FileInfo.Length: Failed to CreateFile.") Exit Function End If Dim length As QWord If GetFileSizeEx(hFile, VarPtr(length)) Then CloseHandle(hFile) Return length Else CloseHandle(hFile) Throw New IOException("FileInfo.Length: Failed to GetFileSize") End If End Function '---------------------------------------------------------------- ' パブリック メソッド '---------------------------------------------------------------- /* Function AppendText() As StreamWriter End Function*/ Function CopyTo(destFileName As String) As FileInfo Return CopyTo(destFileName, False) End Function Function CopyTo(destFileName As String, overwrite As Boolean) As FileInfo File.Copy(FullPath, destFileName, overwrite) Return New FileInfo(destFileName) End Function Function Create() As FileStream Return File.Create(FullPath) End Function /* Function CreateText() As StreamWriter End Function*/ /* Sub Decrypt() End Sub*/ Override Sub Delete() File.Delete(FullPath) End Sub /* Sub Encrypt() End Sub*/ /* Function GetAccessControl() As FileSecurity End Function*/ /* Function GetAccessControl(includeSections As AccessControlSections) As FileScurity End Function*/ Sub MoveTo(destFileName As String) File.Move(FullPath, destFileName) End Sub Function Open(mode As FileMode) As FileStream Return New FileStream(FullPath, mode) End Function Function Open(mode As FileMode, access As FileAccess) As FileStream Return New FileStream(FullPath, mode, access) End Function Function Open(mode As FileMode, access As FileAccess, share As FileShare ) As FileStream Return New FileStream(FullPath, mode, access, share) End Function Function OpenRead() As FileStream Return Open(FileMode.Open, FileAccess.Read, FileShare.Read) End Function Function OpenText() As StreamReader Return New StreamReader(FullPath) End Function Function OpenWrite() As FileStream Return Open(FileMode.Open, FileAccess.Write) End Function /* Function Replace(destinationFileName As String, destinationBackupFileName As String) As FileInfo End Function*/ /* Function Replace(destinationFileName As String, destinationBackupFileName As String, ignoreMetadataErrors As Boolean) As FileInfo End Function*/ /* Sub SetAccessControl(fileSecurity As FileSecurity) End Sub*/ Override Function ToString() As String Return FullPath End Function End Class End Namespace End Namespace