User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 374,011 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,812 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser:
Views: 199 | Replies: 2 | Solved
Reply
Join Date: May 2008
Posts: 3
Reputation: MatrixCA is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
MatrixCA MatrixCA is offline Offline
Newbie Poster

RE: Changing the size of a file.

  #1  
May 9th, 2008
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2008
Posts: 3
Reputation: MatrixCA is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
MatrixCA MatrixCA is offline Offline
Newbie Poster

Re: Changing the size of a file.

  #2  
May 9th, 2008
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.
Reply With Quote  
Join Date: May 2008
Posts: 3
Reputation: MatrixCA is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
MatrixCA MatrixCA is offline Offline
Newbie Poster

Re: Changing the size of a file.

  #3  
May 10th, 2008
I was able to resolve the problem.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb VB.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 10:49 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC