Re: Wish I was using .net
- From: "Gary Nelson" <gn@xxxxxxxxxx>
- Date: Fri, 24 Feb 2006 08:40:05 -0000
Michael,
Two major problems with VB 6 File IO statements. First, they simply
aren't
interoperable with Unix (or IBM MVS) end of line markers. dotNet is.
Second, unless you set len = 1, you can't flush files to disk under
program
control. When writing log files, you either end up with a very, very slow
log file or chance loosing the last few log entries. Yes, both of these
could have been fixed within the construct of the classic BASIC file io
statements, but they were certainly broken in VB 6. I lost count of the
number of times I had to FSO to handle Unix files and I ended up using the
Windows API directly for my logfile class.
Now I'm beginning to understand your problem with VB6 file IO. I just
couldn't understand why FileGet(1, A$, 1) was so superior to Get 1, 1, A$.
You should probably take a short course on binary file IO. It would do you
good (even for .NET development). By the way, I haven't used Line Input #,
nor Input # for about 15 years now. Aside from the additional error trapping
necessary (try opening a file for input that doesn't exist), there is no
comparison in speed. Both Karl and Rick give you samples of how to open your
Unix file and the options of using split, and replace to do what you want.
If the file is not too large, read it at one go. If it is very large read it
in 64K chunks. You would be suprised how fast VB6 file IO is. Using VB6 I
can load a very large file, parse the information, reorganize it, and save
it reorganized in roughly the same time that it takes to copy the file from
the command line. Although binary file IO in .Net is quiet a bit slower than
in VB6 it is still much faster than sequential file IO.
As to Flush, I must admit that it should have been included in VB long ago.
But there is a very simple workaround. Simply close the file and reopen it
after each operation. You would be supprised how fast VB6 can do that. In
fact, if you are creating a log file to which multiple users are writing,
the way to do it is to have each user open it as a locked file, write their
info and close again. Works fine.
Another suggestion, stay away from FSO.
Gary
.
- References:
- Wish I was using .net
- From: Michael C
- Re: Wish I was using .net
- From: MikeD
- Re: Wish I was using .net
- From: Michael C
- Re: Wish I was using .net
- From: Lance Wynn
- Re: Wish I was using .net
- From: Michael C
- Re: Wish I was using .net
- From: Lance Wynn
- Re: Wish I was using .net
- From: Michael C
- Re: Wish I was using .net
- From: Michael D. Ober
- Re: Wish I was using .net
- From: Ken Halter
- Re: Wish I was using .net
- From: Michael D. Ober
- Re: Wish I was using .net
- From: Michael C
- Re: Wish I was using .net
- From: Stefan Berglund
- Re: Wish I was using .net
- From: Michael C
- Re: Wish I was using .net
- From: Ken Halter
- Re: Wish I was using .net
- From: Michael C
- Re: Wish I was using .net
- From: Ken Halter
- Re: Wish I was using .net
- From: Michael D. Ober
- Wish I was using .net
- Prev by Date: Re: Event in VB raised more than once.
- Next by Date: Re: Wish I was using .net
- Previous by thread: Re: Wish I was using .net
- Next by thread: Re: Wish I was using .net
- Index(es):
Relevant Pages
|