Append to beginning of file

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2005
Posts: 4
Reputation: clam is an unknown quantity at this point 
Solved Threads: 0
clam clam is offline Offline
Newbie Poster

Append to beginning of file

 
0
  #1
Aug 29th, 2005
Hi Guys.

Basically I was wondering if it is possible to Append to the START of the file, instead of the end?

For a bit of background information, I have a lump of raw data in hex (they are samples collected from a microphone on a microcontroller then transferred to the PC via RS232). I was planning on dumping them straight into a file, then adding some .wav header information to the beginning of the file, then THEORETICALLY i should be able to use it as a normal .wav file. Does anyone see a problem with this?

Anyway, thanks for any input.

Cheers,

clam
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 638
Reputation: Thong_Ispector is an unknown quantity at this point 
Solved Threads: 18
Thong_Ispector's Avatar
Thong_Ispector Thong_Ispector is offline Offline
Practically a Master Poster

Re: Append to beginning of file

 
0
  #2
Aug 31st, 2005
I may be missing something but why not write the header data to a second file then append your data to it?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 4
Reputation: clam is an unknown quantity at this point 
Solved Threads: 0
clam clam is offline Offline
Newbie Poster

Re: Append to beginning of file

 
0
  #3
Aug 31st, 2005
I was just about to post explaining that, sorry.

I tried it:

Open filename For Input As #1
Open filename2 For Append As #2

Write #2, "WAVE HEADER INFORMATION"

Dim templine As String

Do Until (EOF(1) = True)
Input #1, templine
Write #2, templine
Loop

Close


The first file is 186kb, and after adding header information (currently just "WAVE HEADER INFORMATION") then appending all of the first file to the second.... the second file is only 85kb

I assume this is because the entire file is on one line or something?
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 638
Reputation: Thong_Ispector is an unknown quantity at this point 
Solved Threads: 18
Thong_Ispector's Avatar
Thong_Ispector Thong_Ispector is offline Offline
Practically a Master Poster

Re: Append to beginning of file

 
0
  #4
Sep 2nd, 2005
Sorry I did not get back sooner..
I ran that after making text files and it worked fine.

My file size doubled and all of the info was inside.

The size on disk remained the same... but the data size increased correctly..

I am also interested in your code for saving the raw file to disk.

Are you using VB5 or ?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 5936 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC