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 1 1355
Oh yeah, here is the line that it is erroring out on saying that the file is
already open:
Dim srMameGamesCFG As StreamReader = New
StreamReader(Application.StartupPath & "\mamegames.cfg")
Thanks,
John
"jcrouse" <me> wrote in message news:eG*************@TK2MSFTNGP12.phx.gbl... 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Marco Nicosia |
last post by:
Hello gang,
My coworker and I are writing a Python class for the other developers
within our team. This class is supposed to encapsulate several things,
including daemonizing, setting up...
|
by: Sara Khalatbari |
last post by:
Dear friends
In a code, I'm opening a file to read. Like :
lines = open(filename).readlines()
& I'm never closing it.
I'm not writing in that file, I just read it.
Will it cause any problems...
|
by: Dr. Know |
last post by:
I am working on an ASP page that writes to several databases, ranging
from MDBs to x-base.
One of the tasks involves using an existing highest value from the DB
and incrementing it before...
|
by: TheAd |
last post by:
At this moment I use MsAccess and i can build about every databound
application i want. Who knows about a serious open source alternative?
Because Windows will be a client platform for some time, i...
|
by: Charles Law |
last post by:
My first thought was to call
WorkerThread.Suspend
but the help cautions against this (for good reason) because the caller has
no control over where the thread actually stops, and it might have...
|
by: Ryan Liu |
last post by:
Hi,
Both way works, I'd just ask some experts which way is better?
My application creates a log file daily.
Now each time when I write a log, I will open the file and append to the
end....
|
by: ahammad |
last post by:
I have an MFC application that opens up a Word document for editing using automation. Is there a way to pause or freeze the MFC application while the Word doc is being edited? After the editing is...
|
by: gyanendar |
last post by:
Hi All,
I have to design a web page in which all file(pdf) present in particular folder is visible.Onclicking particular Item,the file should open in new window.
There is link on parent window...
|
by: sebastian.noack |
last post by:
Hi,
is there a way to or at least a reason why I can not use tarfile to
create a gzip or bunzip2 compressed archive in the memory?
You might might wanna answer "use StringIO" but this isn't...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |