SetFileLength - Set the length in bytes of the input file
' Set the length in bytes of the input file
' Example:
' Dim filePath As String = "c:\test.txt"
' MessageBox.Show("Original length: " & New System.IO.FileInfo(filePath)
' .Length)
' SetFileLength(filePath, 50000)
' MessageBox.Show("New length: " & New System.IO.FileInfo(filePath).Length)
Sub SetFileLength(ByVal filePath As String, ByVal sizeInBytes As Long)
Dim fs As System.IO.FileStream
Try
fs = New System.IO.FileStream(filePath, IO.FileMode.Open)
fs.SetLength(sizeInBytes)
Finally
If Not fs Is Nothing Then fs.Close()
End Try
End Sub