J
jcrouse
This is sort of a revisited item from about two months ago (don't get
mad Cor) with additional code. I am creating a batch file called
CreateMameGames.bat. I am then running that batch file to create a text file
called MameGames.cfg. Later on in my code I parse through the file and pull
out information. This all worked great but the file is 25MB. In an attempt
to spped up the parsing I added code to take the MameGames.cfg file, open
it, read it a line at a time and if I need that line later, write it to
another text file called Games.cfg. The problem is that the creation on the
25MB file, MameGames.cfg doesn't complete before I declare it with a
streamreader of the slimming down of the file. I have even put in a timer to
pause 60 seconds, but no luck. The few times it has run it did great,
reducing the file to 700kb in size. What are some of my options here? I run
it as a process and thought the the process.wait for exit would do it, but
it doesn't. Here is my code:
Dim strInput As String = Application.StartupPath & "\CreateMameGamesCFG.bat"
MsgBox("Please be patient. This operation could take a minute or two to
complete.", MsgBoxStyle.Information, "CPViewer")
Me.Cursor = Cursors.WaitCursor
Dim p As New System.Diagnostics.ProcessStartInfo
p.CreateNoWindow = True
p.WindowStyle = ProcessWindowStyle.Hidden
p.FileName = strInput
p.UseShellExecute = True
System.Diagnostics.Process.Start(p)
Dim pr As System.Diagnostics.Process = System.Diagnostics.Process.Start(p)
pr.WaitForExit()
pr.Close()
pr.Dispose()
Me.Cursor = Cursors.Default
Start = Microsoft.VisualBasic.DateAndTime.Timer
Finish = Start + 60.0
Do While Microsoft.VisualBasic.DateAndTime.Timer < Finish
Loop
MsgBox("Your file has been created successfully.", MsgBoxStyle.Information,
"CPViewer")
Dim srMameGamesCFG As StreamReader = New
StreamReader(Application.StartupPath & "\mamegames.cfg")
Dim sw As StreamWriter = New StreamWriter(Application.StartupPath &
"\Games.cfg")
strLine = "1"
Do Until strLine Is Nothing
strLine = srMameGamesCFG.ReadLine()
If strLine Is Nothing Then
Exit Do
ElseIf strLine.StartsWith("game (") = True Then
sw.WriteLine(strLine)
ElseIf strLine.StartsWith(vbTab & "name ") = True Then
sw.WriteLine(strLine)
ElseIf strLine.StartsWith(vbTab & "description ") = True Then
sw.WriteLine(strLine)
ElseIf strLine.StartsWith(vbTab & "video ( screen") = True Then
sw.WriteLine(strLine)
ElseIf strLine.Equals(")") = True Then
sw.WriteLine(strLine)
End If
Loop
sw.Close()
Thanks,
John
mad Cor) with additional code. I am creating a batch file called
CreateMameGames.bat. I am then running that batch file to create a text file
called MameGames.cfg. Later on in my code I parse through the file and pull
out information. This all worked great but the file is 25MB. In an attempt
to spped up the parsing I added code to take the MameGames.cfg file, open
it, read it a line at a time and if I need that line later, write it to
another text file called Games.cfg. The problem is that the creation on the
25MB file, MameGames.cfg doesn't complete before I declare it with a
streamreader of the slimming down of the file. I have even put in a timer to
pause 60 seconds, but no luck. The few times it has run it did great,
reducing the file to 700kb in size. What are some of my options here? I run
it as a process and thought the the process.wait for exit would do it, but
it doesn't. Here is my code:
Dim strInput As String = Application.StartupPath & "\CreateMameGamesCFG.bat"
MsgBox("Please be patient. This operation could take a minute or two to
complete.", MsgBoxStyle.Information, "CPViewer")
Me.Cursor = Cursors.WaitCursor
Dim p As New System.Diagnostics.ProcessStartInfo
p.CreateNoWindow = True
p.WindowStyle = ProcessWindowStyle.Hidden
p.FileName = strInput
p.UseShellExecute = True
System.Diagnostics.Process.Start(p)
Dim pr As System.Diagnostics.Process = System.Diagnostics.Process.Start(p)
pr.WaitForExit()
pr.Close()
pr.Dispose()
Me.Cursor = Cursors.Default
Start = Microsoft.VisualBasic.DateAndTime.Timer
Finish = Start + 60.0
Do While Microsoft.VisualBasic.DateAndTime.Timer < Finish
Loop
MsgBox("Your file has been created successfully.", MsgBoxStyle.Information,
"CPViewer")
Dim srMameGamesCFG As StreamReader = New
StreamReader(Application.StartupPath & "\mamegames.cfg")
Dim sw As StreamWriter = New StreamWriter(Application.StartupPath &
"\Games.cfg")
strLine = "1"
Do Until strLine Is Nothing
strLine = srMameGamesCFG.ReadLine()
If strLine Is Nothing Then
Exit Do
ElseIf strLine.StartsWith("game (") = True Then
sw.WriteLine(strLine)
ElseIf strLine.StartsWith(vbTab & "name ") = True Then
sw.WriteLine(strLine)
ElseIf strLine.StartsWith(vbTab & "description ") = True Then
sw.WriteLine(strLine)
ElseIf strLine.StartsWith(vbTab & "video ( screen") = True Then
sw.WriteLine(strLine)
ElseIf strLine.Equals(")") = True Then
sw.WriteLine(strLine)
End If
Loop
sw.Close()
Thanks,
John