May 4, 2002

SaveTextFile – Save or append text to a file

‘ Saves a text file. If the destination file already exists,’ its content can be replaced, or the new content can be appended’ at the end of the file, according to the last parameter’ Note: the destination directory must exist, otherwise the file is not’ saved and the function returns

LoadTextFile – Load the contents of a text file

‘ Returns the content of the specified text file’ Note: it can throw an exception’ Usage: Dim FileContent As String = LoadTextFile(“C:Autoexec.bat”)Function LoadTextFile(ByVal FilePath As String) As String Dim sr As System.IO.StreamReader Try sr = New System.IO.StreamReader(FilePath) LoadTextFile = sr.ReadToEnd() Finally If Not sr Is Nothing Then sr.Close() End TryEnd

CopyDirectory – Copy a directory

‘ Copies a source directory to the destination directory.’ The last parameter specifies whether the files already present in the’ destination directory will be overwritten’ – Note: requires Imports System.IO’ – Usage: CopyDirectory(“C:Misc”, “D:MiscBackup”)Sub CopyDirectory(ByVal SourcePath As String, ByVal DestPath As String, _ Optional ByVal Overwrite As Boolean = False)

GetDirectorySize – Calculate the size of a directory

‘ Returns the size of the specified directory’ – Note: requires Imports System.IO’ – Usage: Dim DirSize As Long = GetDirectorySize(“D:Projects”)Function GetDirectorySize(ByVal DirPath As String) As Long Dim DirSize As Long Dim Dir As DirectoryInfo = New DirectoryInfo(DirPath) ‘ add the size of each file Dim ChildFile As FileInfo For

DownloadFile – Send a file to the client browser

‘ Open the standard dialog to download a file located on the server’ whose virtual path is passed as an argument. This routine is useful when’ you want to download a file that is otherwise processed by IIS. ‘ This routine must be included in an page, so that