leontager Posted July 19, 2003 Posted July 19, 2003 hi, I need some help with writing a stream into a file. i've 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. Quote
*Experts* mutant Posted July 20, 2003 *Experts* Posted July 20, 2003 You could add this to your loop: Dim writer As New Io.StreamWriter("ad" & i + 1 & ".html") writer.Write(temp_v) writer.Close() I hope this is what you mean :). Quote
leontager Posted July 20, 2003 Author Posted July 20, 2003 wow thanx alot. that's 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 doesn't exist. Would it automaticlly create it?:confused: Quote
*Experts* mutant Posted July 20, 2003 *Experts* Posted July 20, 2003 :) It automatically creates the file if it doesnt find it. Quote
Leaders dynamic_sysop Posted July 20, 2003 Leaders Posted July 20, 2003 you could specify OpenOrCreate : 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 it's ok. End Sub Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.