|
AddBackslash - Append a backslash to a path if needed
|
Total Hit (4183) |
«Code LangId=2»
' Append a backslash (or any character) at the end of a path
' if it isn't there already
Function AddBackslash(ByVal Path As String, Optional ByVal ch As Char = "\"c) _
As String
If Not Path.EndsWith(ch) Then
AddBackslash = Path & ch
Else
AddBack
....Read More |
Rating
|
|
|
ChangeFileExtension - Modify the extension in a file name
|
Total Hit (3017) |
«Code LangId=2»
' Change the extension of a file name
' if the last argument is True, it adds the extension even if the file doesn't
' have one
Function ChangeFileExtension(ByVal FileName As String, _
ByVal Extension As String, Optional ByVal AddIfMissing As Boolean = False) _
As St
....Read More |
Rating
|
|
|
CompareFiles - Comparing two binary/text files
|
Total Hit (2837) |
«Code LangId=2»' 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
....Read More |
Rating
|
|
|
ConcatenateFiles - Concatenating multiple text files
|
Total Hit (2909) |
«Code LangId=2»
' 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 #Fi
....Read More |
Rating
|
|
|
CopyDirectory - Copy a directory
|
Total Hit (3118) |
«Code LangId=2»
' 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 CopyDire
....Read More |
Rating
|
|
|
FolderHasFiles - Returns whether the specified folder has files
|
Total Hit (2754) |
«Code LangId=2»
' Returns a boolean indicating whether the specified folder has files
Function FolderHasFiles(ByVal folderPath As String) As Boolean
Return System.IO.Directory.GetFiles(folderPath).Length > 0
End Function
«/Code»
|
Rating
|
|
|
|
GetDirectorySize - Calculate the size of a directory
|
Total Hit (2875) |
«Code LangId=2»
' 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(
....Read More |
Rating
|
|
|
|
IsDriveReady - Returns whether a drive is ready
|
Total Hit (3240) |
«Code LangId=2»
' Returns a boolean indicating whether a given drive is ready
' Example: check if the floppy disk drive is ready
' Debug.WriteLine(IsDriveReady("a"))
Function IsDriveReady(ByVal driveLetter As String) As Boolean
If driveLetter.Length = 1 Then driveLetter &= ":\"
Dim
....Read More |
Rating
|
|
|
IsExecutableFile - Returns whether the file is an executable
|
Total Hit (2769) |
«Code LangId=2»
' Returns a boolean indicating whether the file is an executable
Function IsExecutableFile(ByVal filePath As String) As Boolean
' add more extensions if you wish
Dim extensions() As String = New String() {".exe", ".bat", ".com", ".pif"}
' return true if the extension
....Read More |
Rating
|
|
|
IsImageFile - Returns whether the file is an image
|
Total Hit (3757) |
«Code LangId=2»
' Returns a boolean indicating whether the file is an image
Function IsImageFile(ByVal filePath As String) As Boolean
' add more extensions if you wish
Dim extensions() As String = New String() {".bmp", ".jpg", ".jpeg", ".gif", _
".tif", ".tiff", ".png", ".tga",
....Read More |
Rating
|
|
|
IsValidPath - Validating a system path
|
Total Hit (4669) |
«Code LangId=2»' Validate a system path
' Example:
' MessageBox.Show(IsValidPath("C:\Test\Memo.txt")) ' => True
' MessageBox.Show(IsValidPath("\\RemotePC\Test\Memo.txt")) ' => True
' MessageBox.Show(IsValidPath("C:\Test\Mem|o.txt")) ' => False
Function IsValidPath(ByVal p
....Read More |
Rating
|
|
|
LoadTextFile - Load the contents of a text file
|
Total Hit (2872) |
«Code LangId=2»
' 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
....Read More |
Rating
|
|
|
SaveTextFile - Save or append text to a file
|
Total Hit (3734) |
«Code LangId=2»
' 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 th
....Read More |
Rating
|
|
|
SearchFileInDirTree - Searches a file on a directory tree
|
Total Hit (2924) |
«Code LangId=2»
<System.Runtime.InteropServices.DllImport("imagehlp.dll")> Shared Function _
SearchTreeForFile(ByVal rootPath As String, ByVal inputPathName As String, _
ByVal outputPathBuffer As System.Text.StringBuilder) As Boolean
End Function
' Returns the complete path+name of th
....Read More |
Rating
|
|
|
SearchFileOnPath - Searching a file on the system
|
Total Hit (2783) |
«Code LangId=2»<System.Runtime.InteropServices.DllImport("kernel32")> Shared Function _
SearchPath(ByVal tartPath As String, ByVal fileName As String, _
ByVal extension As String, ByVal bufferLength As Integer, _
ByVal buffer As System.Text.StringBuilder, ByVal filePart As String) As
....Read More |
Rating
|
|
|
|
AlwaysOnTheTop - Move a form on top of all other windows
|
Total Hit (2233) |
«Code LangId=1»
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, _
ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_SHOWW
....Read More |
Rating
|
|
|
|
|
|
|
ShortPathName - Convert a long file name to 8.3 format
|
Total Hit (3369) |
«Code LangId=1»Private Declare Function GetShortPathName Lib "kernel32" Alias _
"GetShortPathNameA" (ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Const MAX_PATH = 260
' Convert a long file/path name to a short 8.3 name
' the path m
....Read More |
Rating
|
|
|
|
|
SystemDirectory - The path of the System directory
|
Total Hit (1867) |
«Code LangId=1»
Private Declare Function GetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
' The path of the System directory
Function SystemDirectory() As String
Dim buffer As String * 512, length As Int
....Read More |
Rating
|
|
|
VolumeLabel - Read the label of a disk volume
|
Total Hit (1744) |
«Code LangId=1»' Return the volume label of a disk
' Pass a null string for the current disk
Function VolumeLabel(drive As String) As String
Dim temp As String
On Error Resume Next
temp = Dir$(drive, vbVolume)
' remove the period after the eigth character
VolumeLabel =
....Read More |
Rating
|
|
|
WindowsDirectory - The path of the Windows directory
|
Total Hit (1991) |
«Code LangId=1»Private Declare Function GetWindowsDirectory Lib "kernel32" Alias _
"GetWindowsDirectoryA" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
' Return the path of the Windows directory
Function WindowsDirectory() As String
Dim buffer As String * 512, lengt
....Read More |
Rating
|
|
|
WriteToStdOutput - Write to standard output stream
|
Total Hit (2507) |
«Code LangId=1»
Option Explicit
Private Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) _
As Long
Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, _
lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, _
lpNumberOfBytesWritten As L
....Read More |
Rating
|
|