470,593 Members | 2,509 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,593 developers. It's quick & easy.

file close

I have created a long string and want to save it to a file. I create the
file fine, but there are two additional characters at the end when I view it
in a hex editor "OD" and "OA".

Here is the code I have tried:

FileOpen(1, SaveFileDialog1.FileName, OpenMode.Output,
PrintLine(1, WholeString)

I can find no way to exclude this addition to my file. I tried changing to
FileOpen() with OpenMode.binary, but just got an error

Is there another way to close the file excluding these "OD" & "OA"

Thanks in advance,

Nov 21 '05 #1
1 2970
Here's a very basic example. This will always overwite the text in the file.
If you want it to APPEND then use 'Dim sw As New IO.StreamWriter(sFilename,
True)' instead of 'Dim sw As New IO.StreamWriter(sFilename)' (The keyword
TRUE means append).

Start a new Windows application

Add a button & a textbox to the form

Double-click the button & add this code:

With SaveFileDialog1
.Filter = "Text Files(*.txt)|*.txt|All Files (*.*)|*.*"
.InitialDirectory =
Environment.GetFolderPath(Environment.SpecialFolde r.Desktop)
If .ShowDialog <> DialogResult.OK Then Exit Sub
End With
SaveFile(TextBox1.Text, "C:\SomeFile.txt")

Add this code:

Private Sub SaveFile(ByVal sText As String, ByVal sFilename As String)
Dim sw As New IO.StreamWriter(sFilename)
End Sub

I hope this helps

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by John Marshall | last post: by
3 posts views Thread by Abhas | last post: by
24 posts views Thread by Kelly | last post: by
18 posts views Thread by panig | last post: by
5 posts views Thread by B. Williams | last post: by
6 posts views Thread by =?Utf-8?B?VGhvbWFzWg==?= | last post: by
3 posts views Thread by Yang | last post: by
reply views Thread by Filemaxor | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.