Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • *Experts*
Posted

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 :).

Posted
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:
  • Leaders
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...