help writing to a file

leontager

Well-known member
Joined
Jun 17, 2003
Messages
89
hi, I need some help with writing a stream into a file.

ive got the following code

For i = 0 To v_count - 1
stream = New IO.StreamReader(wc.OpenRead(v_input(i)))
v_temp = stream.ReadToEnd
TextBox1.Text = TextBox1.Text + v_temp
stream.Close()
Next


I would like to modify it to write each stream into a file called
ad1.html, ad2.html and so on, instead of inputing it into an array.
 
You could add this to your loop:
Code:
Dim writer As New Io.StreamWriter("ad" & i + 1 & ".html")
writer.Write(temp_v)
writer.Close()
I hope this is what you mean :).
 
wow thanx alot. thats the second time you helped me mutant. :D :D One thing though. I need it to create the file as well. Not just write because the file doesnt exist. Would it automaticlly create it?:confused:
 
you could specify OpenOrCreate :
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim sFilePath As String = "C:\somefile.html"
        Dim sWriter As New IO.StreamWriter(New IO.FileStream(sFilePath, IO.FileMode.OpenOrCreate, IO.FileAccess.Write))
        sWriter.Write("<font color=""blue"">Private Sub </font> NewHtmlFile()<br><font color=""DarkGreen"">/// a new file you made and wrote to!</font><br><font color=""Blue"">End Sub</font>")
        sWriter.Close()
        Dim pr As Process = New Process()
        pr.Start("IEXPLORE", sFilePath) /// test the html file to see its ok.
    End Sub
 
Back
Top