April 14, 2003

GetFileDescription – Retrieving the description of a file from the registry

‘ Retrieves the description of a file from the registry’ or a null string if the file’s extension isn’t registered’ Example: Debug.WriteLine(GetFileDescription(“D: yc.zip”))Function GetFileDescription(ByVal filePath As String) As String ‘ get the classname from the registry Dim regKey As Microsoft.Win32.RegistryKey Try regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey( New _ System.IO.FileInfo(filePath).Extension) If Not regKey

CompareFiles – Comparing two binary/text files

‘ Returns a boolean indicating whether two files are equal’ Example: Debug.WriteLine(CompareFiles(“D:File1.mdb”, “D:File2.mdb”))Function CompareFiles(ByVal path1 As String, ByVal path2 As String) As Boolean Dim file1 As New System.IO.FileInfo(path1) Dim file2 As New System.IO.FileInfo(path2) Dim stream1, stream2 As System.IO.FileStream ‘ if the length of the 2 files is different, return False

CompactPathToControl – Shorten a path by using ellipses

Shared Function _ GetWindowDC(ByVal hWnd As Integer) As IntegerEnd Function Shared Function _ PathCompactPath(ByVal hDC As Integer, _ ByVal pathBuffer As System.Text.StringBuilder, _ ByVal dx As Integer) As BooleanEnd Function’ Shorten a path by using ellipses, if necessary, so that it fits inside a ‘ window’ If maxWidth=-1 or omitted,

ConcatenateFiles – Concatenating multiple text files

‘ Concatenate a variable number of text files into a single result file” Params:’ – resultFile: the complete path of the result file you want to create’ – header: a string that is written when a file is added to the result file.’ Note: this string can contain the #FilePath#