I think your problem may be that you aren't specifying which encoding to
se ---
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemIOStreamWriterClassTopic.asp
However the text writer should do the job for you as well.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiotextwriterclasstopic.asp
--
W.G. Ryan MVP (Windows Embedded)
TiBA Solutions
www.tibasolutions.com |
www.devbuzz.com |
www.knowdotnet.com [quoted text, click to view] "poldoj" <poldoj2002@gmail.com> wrote in message
news:#tkvlh47EHA.3856@tk2msftngp13.phx.gbl...
> Hi all, I am trying to write the content of a variable to a text file. I
am
> currently switching from VB 6 code to VB.NET. Here is the code in my vb 6
> applications (this code works)
> ------------------------
> ...
> ...
> FileName$ = CommonDialog1.FileName
> For i = 0 To List1.ListCount - 1
> variable01 = variable01 & List1.List(i) & vbCrLf
> Next
> Const ForReading = 1, ForWriting = 2
> Dim fso, f, ra
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set f = fso.OpenTextFile(FileName$, ForWriting, True)
> f.Write variable01
> ...
> ...
> ------------------------
> This code just retrive the text from a list box and write a text file. I
> have tried to convert to VB.Net without success, here's my attempt:
> ------------------------
> ...
> ...
> Dim FileName As String
>
> Dim hold_temp As String
>
> If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
>
> FileName = SaveFileDialog1.FileName
>
> Dim file As System.IO.FileStream
>
> file = System.IO.File.Create(FileName)
>
> file.Close()
>
> Dim fw As StreamWriter
>
> fw = New StreamWriter(FileName, False)
>
> Dim MainArray() As String
>
> MainArray = TextBox1.Lines
>
> Dim i
>
> For i = 0 To MainArray.GetUpperBound(0)
>
> hold_temp += MainArray(i) & vbCrLf
>
> Next
>
> fw.Write(hold_temp)
>
> fw.Close()
>
> End If
>
> ...
> ...
> ------------------------
> This code in vb.net create a text files that looks like at that in vb6 but
> if I try to read it, it return me strange characters. I thinks I missed
the
> part with the "createobjetc" of the vb 6.
>
>
>
> Thanks!
>
>