0

Does anyone know how to change the value of FS.Length? I keep getting that it's read only.

I need to read a file, let's say it's 100 bytes in size. After some data manipulation, the file becomes 40 bytes. When I write the file back , it writes the 40 bytes plus the remainder of the file thus the file remains at 100 bytes.

I know that if I read the file as File A, write it back as File B and then delete File A would probably work but I want to overwrite the existing file.

I have noticed the the value of FS.Length does not change although the data string that I am writing is 40 bytes.

1
Contributor
2
Replies
3
Views
9 Years
Discussion Span
Last Post by MatrixCA
0

Here's what I have so far:

fs = f.open
lBytes = fs.Length

Dim fileData(lBytes) As Byte
fs.Read(fileData, 0, lBytes)
ModifyFileData(fileData)
fs.Close()

fs = f.OpenWrite
fs.Write(fileData, 0, fileData.Length)
fs.Close()

The code may not be pretty but it's a start.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.