How to wirte a char to a specified location in a txt file?

G

Guest

Hi,Everybody:
In EVB(or VB6), WriteFile() function starts writing data
to the file at the position indicated by the file pointer.
After the write operation has been completed, the file
pointer is adjusted by the number of bytes actually
written. But in VB.net which function can replace it? May
i use System.IO.FileStream.Seek locate the location and
then use System.IO.streamwriter to write char to txt file?

FS = New IO.FileStream(workDir & "\" & appInputFile,
IO.FileMode.Create, IO.FileAccess.Write)

sw = New IO.StreamWriter(FS)

FS.Seek((CurrentPoint - 1) *
FixedLen,IO.SeekOrigin.Current)

sw.Write(string)
 
H

Herfried K. Wagner [MVP]

* said:
In EVB(or VB6), WriteFile() function starts writing data
to the file at the position indicated by the file pointer.
After the write operation has been completed, the file
pointer is adjusted by the number of bytes actually
written. But in VB.net which function can replace it? May
i use System.IO.FileStream.Seek locate the location and
then use System.IO.streamwriter to write char to txt file?

FS = New IO.FileStream(workDir & "\" & appInputFile,
IO.FileMode.Create, IO.FileAccess.Write)

sw = New IO.StreamWriter(FS)

FS.Seek((CurrentPoint - 1) *
FixedLen,IO.SeekOrigin.Current)

sw.Write(string)

Why not test it on your own?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top