devxlogo

SetFileLength – Set the length in bytes of the input file

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:	est.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 TryEnd Sub

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist