|
Show us how your txt is formatted
If it's something like "name=value" then you could do something like that
a) string[] lines = File.ReadAllLines("highscores.txt")
b) create a class:
struct Highscore
{
public string name;
public int score;
}
b)
List<Highscore> scores = new List<Highscore>();
foreach line in lines {
Highscore h = new Highscore();
h.name = line.Substring(0, line.IndexOf('='));
h.score = int.Parse(line.Substring(line.IndexOf('=')+1));
scores.Add(h);
}
c)
scores.Sort(... some IComparer to sort for score ...)
d)
for(int i=0; i<10; i++)
listbox.Add(scores[i].name);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
peter 0,333333333333333
peter 1,33333333333333
thats how its look like
Newbie untill I die!
|
|
|
|
|
Hi everyone,
Posting for the first time here - this looks to be a very active forum.
I have some data in an htm file, enclosed in "pre" tags (well at least the beginning tag is there). It looks like this:
<small>----- --------- ----- --------- ---- ------------------------------------- ---------------- ---------- -------- ---------------- ----------------------
Official Pace Chip Gender Category Split Split Split
Place Gun Time km Time # Name City Plce/Tot Plce/Tot Category @10km @15km @20km
----- --------- ----- --------- ---- ------------------------------------- ---------------- ---------- -------- ---------------- ----------------------
1 1:37:58.2 3:16 1:37:58.2 3 BETCHIM, NOURDDINE Montreal 1/2297 1/277 Men 30 - 34 32:37 49:24 1:05:25
2 1:37:59.9 3:16 1:37:59.2 2 NSENGIYUMVA, JOSEPH Ottawa 2/2297 1/140 Men 25 - 29 32:37 49:23 1:05:26
3 1:38:50.0 3:18 1:38:50.0 5 DEHBI, AMOR Montreal 3/2297 2/277 Men 30 - 34 32:37 49:23 1:05:46
4 1:40:15.4 3:21 1:40:15.4 7 KASSAP, DANNY Toronto 4/2297 1/52 Men 20 - 24 32:38 49:23 1:05:35
5 1:42:04.6 3:25 1:42:04.6 19 PAULING, RYAN Rochester 5/2297 2/140 Men 25 - 29 33:34 50:50 1:07:50
6 1:42:25.0 3:25 1:42:25.0 1817 VOLLMER, MARK Guelph 6/2297 3/140 Men 25 - 29 33:33 50:49 1:07:49
7 1:43:10.6 3:27 1:43:10.6 12 GRAF, ERIC Meadville 7/2297 4/140 Men 25 - 29 33:48 51:22 1:08:27
8 1:43:14.8 3:27 1:43:13.8 16 PRINCIC, DANIEL Meadville 8/2297 5/140 Men 25 - 29 34:46 52:03 1:08:42
9 1:43:19.5 3:27 1:43:18.8 4462 KEMP, PAUL Toronto 9/2297 1/354 Men 35 - 39 34:12 51:33 1:08:25
10 1:43:44.5 3:28 1:43:42.9 1256 MACDONALD, JAY Hamilton 10/2297 6/140 Men 25 - 29 33:33 50:50 1:07:49 </small>
I'd like to convert this to XML, I think it's best to do this programmatically. I'm considering using C# or Perl to do this, but I'm open to other ideas. I have the following questions:
- With Perl, setting up my regex will be elegant, but I don't know if Active Perl has any way of producing an XML file.
- With C#, it might be faster, but I don't know what class I would use to produce the XML and serialize it to disk.
All information and advice is welcome!
Thanks a lot,
Richard
|
|
|
|
|
RichardInToronto wrote: I don't know what class I would use to produce the XML and serialize it to disk.
Look in the System.Xml namespace. Also look for articles on CodeProject and msdn.microsoft.com that might be tutorial type articles.
YOu can use a DOM object System.Xml.XmlDocument or perhaps a XmlWriter would work better for your solution.
led mike
|
|
|
|
|
Thanks for the help Mike.
|
|
|
|
|
use regular expression object in C#
1. Use Regex
2. Do Grouping in Regex
3. Use MatchEvaluator if needed
4. Add the grouping result values to the dataset.
5. Save Datset to Xml.
You are done!
Sreenath
|
|
|
|
|
Thanks for your help Sreenath.
|
|
|
|
|
Hi All,
I Have created a windows service in C# and I want to run an exe which was created by me earlier from this service when the service starts.
I can see the exe running in the task manager but I am unable to see the UI of the exe
Please help me as this is urgent.
Thanks.
Kalyan
|
|
|
|
|
If you go into the services control panel and double click your service, you will see a tab in the ensuing dialog labelled "Log On". Click on that and then select the checkbox under the "Local System account" radio button marked "Allow service to interact with the desktop". I'm not sure if this will work for you, but give it a try.
The preferrable way to manage your own services is to create a service with no UI and then build a second Windows Forms application (possibly even one that runs in the tray) that can connect to the service and control it. You can also use remoting if you want to communicate with your service in some other way than just telling it to start, stop, and restart.
Hope that helps.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I am working on an application that has hundreds of try/catch blocks that output to Console.Writeline() on error. This is great for debug mode as it gets picked up in Visual Studio. I am curious where the output goes when I am in release mode. Is there an app that can pick this up? Are there serious performance implications for leaving them in for Release mode?
Thanks!
Hogan
|
|
|
|
|
If there is no Window open that catches stdout (like a Console or the VS output window), then imho it goes nowhere. Use Trace.WriteLine to print debug output.
You can capture it with DebugView in Debug and Release mode
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Didn't work. Put my app in release mode. Launched it in Visual Studio .NET and stand alone and nothing got logged. Guess I'll have to do something else.
Thanks
Hogan
|
|
|
|
|
Works fine for me, DebugView captures my Trace.WriteLine .
You might also try this:
DefaultTraceListener listener = new DefaultTraceListener();
listener.WriteLine("TEST");
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Greeg,
Sorry about my quick response. I missed using the Trace part. I was just using my Console.Writeline... I think I am going to convert them all to using NLog in Release mode so I can turn them off if I don't need them. Thanks for your help!
Hogan
|
|
|
|
|
I want to access only hidden files from a specific folder. Is there any property that fullfills my need....
Thanks
Syed Shahid Hussain
|
|
|
|
|
see FileInfo.Attributes
|
|
|
|
|
Hi there.
Apologies in advance if i'm posting this question in the wrong section.
i'm wondering if it's possible to change the layout of the rdlc report at runtime (preferably without having to generate the .rdlc file from code). For instance, i want the user to be able to select which columns to display in a matrix. Based on those choices, the matrix must adjust to hide those non-selected columns.
Using the "expression to determine visiblity" feature hides the data, but there's a blank gap left in its place (makes the report look really... dodgy ). I was thinking of putting in a function that said if the parameter passed through was false, set the matrix column width to 0 - except that it won't let me do that.
So, is there another way? Short of programmatically creating the report, or having awful-looking gaps.
Thanks
|
|
|
|
|
The way I have done things like this in the past is have a dynamic XML generator. The XML will be used as the Code behind the report.
|
|
|
|
|
hi
i want to play stream video from my hdd, How to do ??
thanks .
|
|
|
|
|
I have a ListView and a custom IComparer for sorting. Which was working fine. I added a couple groups to the ListView , and now the sorting does nothing. The IComparer is processing each ListViewItem , the ListView just seems to ignore it.
Has anybody dealt with this? What am I missing?
|
|
|
|
|
Hi!
Moved my project from school to my home PC using a USB. Done that many times and it have worked.
Now I get this message:
Parameter is not valid. C:\Documents and Settings\Peter\Mina dokument\Visual Studio 2005\Projects\Bamse\Bamse\Form2.Designer.cs 111 0
And it points to this line:
this.picBoxPase.BackgroundImage = global::Bamse.Properties.Resources.påse;
The resource "påse" is in my project folder.
Any ideas?
Newbie untill I die!
|
|
|
|
|
It won't compile ? This line is in your auto generated code, so delete it and set the property again in the IDE and see how you go.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi hristo1977,
Well it happened with me once too.
When you specify a resource in your project, VS does not copy that resource to your project. It just takes a reference of that resource which is actually present on your hard drive.
If you have chose the option to embed that resource in your build, then that resource is embedded during compile time. Meaning, at no time, it is actually included into your project.
So, you need to check if the resource it points to is actually present on your drive. Click the resource and check out its path in the properties window and make sure it points to the right thing.
Hopefully it was helpful.
*** Who said nothing is impossible? I have been doing it for a long time ***
|
|
|
|
|
Hi!
The resource is there! But I still get that damn message.
Newbie untill I die!
|
|
|
|
|
Try deleting that reference from the project and include it afresh.
That might work.
*** Who said nothing is impossible? I have been doing it for a long time ***
|
|
|
|