Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB7
Expertise: Intermediate
Sep 29, 2003

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
Marco Bellinaso
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap