|
-
Jun 29th, 2012, 07:43 AM
#1
Thread Starter
Junior Member
Error in streamwriter/stringreader code
What I am trying to do is to split single text files into three lines then assign those three lines to x,y,z points allowing me to choose which points to export into a new file. I am doing this with multiple text files and combining them all into a single file. However, the code I am using below seems to not want to print the x, y data for my first file.
Dim SW As New IO.StreamWriter(OutPutFile)
Dim Files As String() = IO.Directory.GetFiles(StartDirectory, "*.txt")
Dim File As String
Dim scale As String = "scale" & vbCrLf & "all" & vbCrLf & vbCrLf & "0,0" & vbCrLf & "0.0393700787"
For Each File In Files
Dim SR As New IO.StreamReader(File)
SW.WriteLine("Circle")
Do Until SR.EndOfStream
Dim TempString As String = SR.ReadLine
Dim TempString1 As String = Replace(TempString, " ", vbCrLf)
Dim SR2 As New IO.StringReader(TempString1)
Dim x As String = SR2.ReadLine
Dim y As String = SR2.ReadLine
Dim z As String = SR2.ReadLine
SW.WriteLine(x & "," & y)
Loop
SW.WriteLine(TextBox3.Text * 25.4)
Next
SW.WriteLine(scale)
SW.WriteLine("Zoom extents")
SW.Flush()
SW.Close()
Close()
This returns:
Circle
0.4953
Circle
0.99085393843124,-0.38163053628774
0.4953
Circle
4.95256986922053,-1.55010388217933
0.4953
and it should return:
Circle
-3.02335715352036,0.81239141747804
0.4953
Circle
0.99085393843124,-0.38163053628774
0.4953
Circle
4.95256986922053,-1.55010388217933
0.4953
What am I doing wrong?
-
Jun 29th, 2012, 07:52 AM
#2
Thread Starter
Junior Member
Re: Error in streamwriter/stringreader code
Nevermind, the one file it was supposed to copy somehow got its data overwritten by nothing...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|