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.Sta rtupPath & "\CreateMameGam esCFG.bat"
MsgBox("Please be patient. This operation could take a minute or two to
complete.", MsgBoxStyle.Inf ormation, "CPViewer")
Me.Cursor = Cursors.WaitCur sor
Dim p As New System.Diagnost ics.ProcessStar tInfo
p.CreateNoWindo w = True
p.WindowStyle = ProcessWindowSt yle.Hidden
p.FileName = strInput
p.UseShellExecu te = True
System.Diagnost ics.Process.Sta rt(p)
Dim pr As System.Diagnost ics.Process = System.Diagnost ics.Process.Sta rt(p)
pr.WaitForExit( )
pr.Close()
pr.Dispose()
Me.Cursor = Cursors.Default
Start = Microsoft.Visua lBasic.DateAndT ime.Timer
Finish = Start + 60.0
Do While Microsoft.Visua lBasic.DateAndT ime.Timer < Finish
Loop
MsgBox("Your file has been created successfully.", MsgBoxStyle.Inf ormation,
"CPViewer")
Dim srMameGamesCFG As StreamReader = New
StreamReader(Ap plication.Start upPath & "\mamegames.cfg ")
Dim sw As StreamWriter = New StreamWriter(Ap plication.Start upPath &
"\Games.cfg ")
strLine = "1"
Do Until strLine Is Nothing
strLine = srMameGamesCFG. ReadLine()
If strLine Is Nothing Then
Exit Do
ElseIf strLine.StartsW ith("game (") = True Then
sw.WriteLine(st rLine)
ElseIf strLine.StartsW ith(vbTab & "name ") = True Then
sw.WriteLine(st rLine)
ElseIf strLine.StartsW ith(vbTab & "descriptio n ") = True Then
sw.WriteLine(st rLine)
ElseIf strLine.StartsW ith(vbTab & "video ( screen") = True Then
sw.WriteLine(st rLine)
ElseIf strLine.Equals( ")") = True Then
sw.WriteLine(st rLine)
End If
Loop
sw.Close()
Thanks,
John 1 1394
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(Ap plication.Start upPath & "\mamegames.cfg ")
Thanks,
John
"jcrouse" <me> wrote in message news:eG******** *****@TK2MSFTNG P12.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.Sta rtupPath &
"\CreateMameGam esCFG.bat" MsgBox("Please be patient. This operation could take a minute or two to complete.", MsgBoxStyle.Inf ormation, "CPViewer")
Me.Cursor = Cursors.WaitCur sor
Dim p As New System.Diagnost ics.ProcessStar tInfo
p.CreateNoWindo w = True
p.WindowStyle = ProcessWindowSt yle.Hidden
p.FileName = strInput
p.UseShellExecu te = True
System.Diagnost ics.Process.Sta rt(p)
Dim pr As System.Diagnost ics.Process = System.Diagnost ics.Process.Sta rt(p)
pr.WaitForExit( )
pr.Close()
pr.Dispose()
Me.Cursor = Cursors.Default
Start = Microsoft.Visua lBasic.DateAndT ime.Timer
Finish = Start + 60.0
Do While Microsoft.Visua lBasic.DateAndT ime.Timer < Finish
Loop
MsgBox("Your file has been created successfully.",
MsgBoxStyle.Inf ormation, "CPViewer")
Dim srMameGamesCFG As StreamReader = New StreamReader(Ap plication.Start upPath & "\mamegames.cfg ")
Dim sw As StreamWriter = New StreamWriter(Ap plication.Start upPath & "\Games.cfg ")
strLine = "1"
Do Until strLine Is Nothing
strLine = srMameGamesCFG. ReadLine()
If strLine Is Nothing Then
Exit Do
ElseIf strLine.StartsW ith("game (") = True Then
sw.WriteLine(st rLine)
ElseIf strLine.StartsW ith(vbTab & "name ") = True Then
sw.WriteLine(st rLine)
ElseIf strLine.StartsW ith(vbTab & "descriptio n ") = True Then
sw.WriteLine(st rLine)
ElseIf strLine.StartsW ith(vbTab & "video ( screen") = True Then
sw.WriteLine(st rLine)
ElseIf strLine.Equals( ")") = True Then
sw.WriteLine(st rLine)
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 logging, and spawning a thread to
host an XML-RPC server.
I'm having a real problem with logging.Logger and threading.Thread. In
the main thread, we set up two loggers, each with file handlers. We
then spawn the xml-rpc server thread, and allow the...
|
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 if you open a file to read
& never close it?
|
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 inserting a new record.
I am using Application.Lock and .Unlock together with an application
variable to negotiate access to the DB routine to one session (user)
at a time. This is to ensure that the ID numbers are cleanly
incremented, and that no...
|
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 prefer a
solution that (also) supports Windows.
On the net I found a number of products that i looked at, but none of
them gave me the impression of a serious candidate at this moment
(KNoda, Gnome DB Manager, InterBase...).
2 additional...
|
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 a lock
pending, for example.
I want to be able to stop a thread temporarily, and then optionally resume
it or stop it for good.
| |
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. Ocz, if the file is not exist(e.g. another day), it will creates the
file first.
|
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 done and Word is closed, I want the MFC application to regain control and continue with doing something else. It's kind of like having it take a break until Microsoft Word is closed.
How can this be implemented?
|
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 which show wether the newly open window is still open or closed.
I have implemented the first part through <a href="JavaScript..."..>txt</a>
and able to view the file in new window.
But the second part ,I am not able to implement.
I try with this...
|
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 such easy
as it seems to be. ;) I am using Python 2.5.2, by the way. I think
this is a bug in at least in this version of python, but maybe
StringIO isn't just file-like enough for this "korky" tarfile module.
But this would conflict with its...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |