Current location: Hot Scripts Forums » Programming Languages » Windows .NET Programming » StreamWriter probs

StreamWriter probs

 
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-07-04, 03:15 PM
ZodKneelsFirst ZodKneelsFirst is offline
New Member
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
StreamWriter probs

Hello,

Very novicey I'm afraid so feel free to sneer.

This code is creating a new file OK.
what I don't unsderstand is why the file appears to be blank after termination.

Ta.

Imports System.IO.Stream
Imports System
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Dim strPath As String = "C:\VSdata\FileReader\outputfile"
Dim filename As Int16 = 1
Dim ext As String = ".txt"
Dim fsIn As New FileStream("C:\VSdata\FileReader\testfile.txt", FileMode.Open)
Dim srIn As New StreamReader(fsIn)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
While File.Exists(strPath + filename.ToString() + ext)
filename += 1
End While

Try
Dim fsOut As New FileStream(strPath + filename.ToString() + ext, FileMode.OpenOrCreate)
Dim swOut As StreamWriter = New StreamWriter(fsOut)
Dim inString As String
While (inString <> Nothing)
Try
swOut.WriteLine(inString)
inString = srIn.ReadLine()
Catch excp As System.Exception
MsgBox(excp.Message)
End Try
End While

Catch exp As System.Exception
MsgBox(exp.Message)
End Try

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

End Sub
End Class
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 12:59 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.