Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File System Object

Status
Not open for further replies.

Swi

Programmer
Feb 4, 2002
1,966
US
I work with a lot of line sequential and record sequential files. How do I read an input file in and manipulate data and then create an output file using the File System Object? Right now I have a method that works but I am looking for better performance.

FYI - I frequently deal with files that have a record length of over 2,000 and file sizes of 1GB.

Thank you. Swi
 
Ouch! Those are pretty big files. If you're dealing with records, then it would be wise to create a class module to represent a record, as those contained in the file. So essentially, for each record in the file, an object gets instantiated from your class module, and can be thus made available for manipulation. (I use dynamic arrays of 'record' objects for this purpose). Once this manipulation is done, you can write this back to a new data file, or overwrite the existing data file with the new info.

Use the TextStream Object in conjunction with the FileSystemObject to read from the data file - The TextStream object has a .ReadLine() method, which is useful, if not designed for line sequential files.

Hope this helps! Thanks!
LeGo PiEcE

"The Computer Spock! Destroy it!" - Captain James T. Kirk
 
PS - The Visual Basic Black book by Steven Holzner, (Coriolis) has great coverage on file handling and functions, associated with the FileSystemObject. Peace
Lego

"I don't think we have the right or the wisdom to interfere with an alien tribe no matter how it's evolving!" - Captain James T. Kirk

"Your people must embrace these words and the words that follow, for their true meanings are..." - Captain James T. Kirk (same episode)
 
So you'll use the filesystem object in VB6???
I am writing a VB6 application and need to launch an application on the user's computer, and can't depend on the user's path to the target application being the same as the path to that same application on my machine.

(In .asp on a web server I would use server.mappath, but I don't know if VB6 have an eqivalent)

So I quess the question is: How do you determine the path to a file at run time?

Thanks in advance!

Doug
 
LegoPiece,

When reading in a Line Sequential file using the File System Object, I assume that it reads it from the CRLF. What if the file is Record Sequential (no CRLF)? What does the File System Object return then? The code I have now that does not use the File System Object takes that into account. I have got the File System Object to read in a Line Sequential File but how do I step through the records one at a time manipulating the data? What my code does now is finds out the Record Length if it can, if not the user must enter the record length, and then it calculats the number of records by taking the total amount of bytes and dividing it by the record length. Then I read a record at a time using a DO loop and manipulate it and write it out to an ouput file while keeping a counter on the number of records. Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top