|
It is limited - but is is simple, and quick to set up and use.
For simple tasks, it is fine - for more complex stuff I roll my own, but that would be more likely to be a datafile or a template than an INI file anyway.
No users? Lucky you! They just pay you to produce software nobody uses?
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Sooo...,
For maximum flexibly still the old ground hugging ini file is best it appears to the best, users can open see and scr*w up!
if (File.Exists(INIPath + "\\MeteringData.ini"))
{
StreamReader sr = new StreamReader(INIPath + "\\MeteringData.ini");
Defaults = sr.ReadToEnd();
sr.Close();
string[] Values = Defaults.Split(delimetersChars);
foreach (string v in Values)
{
a++;
char[] separator = { '=' };
string[] Key = v.Split(separator);
if (Key.Length != 2) continue;
Key[0] = Key[0].Trim();
Key[1] = Key[1].Trim();
if(Key[0] == "Location")
{
LocationData = Key[1];
}
The really nice thing is when you get a panic stricken email/phone call "we have broken something help" send them a fresh version of the ini file modded to their specs and 'Hussar!' it works.
Glenn
|
|
|
|
|
glennPattonWork wrote: For maximum flexibly
XML.
|
|
|
|
|
XML, really? I need a good example of how to do it, also with our clients editing/modding the file must be stupidly easy. The number times I have received an Email at quarter to home on Friday that basically says "<thing> does not run we need <thing> running for a demo on Saturday am", (I mean a Demo on Saturday morning?)....
|
|
|
|
|
glennPattonWork wrote: with our clients editing/modding the file must be stupidly easy.
Write an editor for them to use and/or have something like Tools/Options.
|
|
|
|
|
That depends on the product and user base but defensive programming can minimize many problems.
|
|
|
|
|
OriginalGriff wrote: produce software nobody uses
Batch processing, Windows Services, etc.
And stuff that I write for myself that no one else uses.
|
|
|
|
|
Hi Gurus,
I am using RegEx class for parsing some strings of the following format
[Hello World message 234...]
What is the expression that I need to use to format the above string??
Thanks...
Sunil
|
|
|
|
|
What do you mean by "formatting the above string"??
Are you looking to pull information out of the string?? What would that data be??
|
|
|
|
|
Hi Dave,
This is my requirement. I read a line from a file, which is in the following format: [Some message 123...]
So I would want to create a RegEx pattern for the above format. What would be the expression for this case. I tried this but it failed while calling method RegEx.Match():
RegEx _exp = new Regex(@"^\[(?<message>\w+)]", RegexOptions.IgnoreCase);
Sunil
|
|
|
|
|
That still doesn't help. Why do you need a regex, what problem is it supposed to solve?
|
|
|
|
|
sunilkpv wrote: So I would want to create a RegEx pattern for the above format
TO DO WHAT??
|
|
|
|
|
Why are you using a RegEx when you can easily separate the tokens of the message with the String.Split() [^] method? Perhaps if you explain exactly what you are trying to do we can make some more informed suggestions.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
There is a Regular Expression forum.
Perhaps you should provide more examples and the results you want.
If you want to separate the message part from the number part, perhaps something like this might help:
@"(?'message'[^\d]*)(?'number'[\d]*)"
or
@"(?'message'.*?) message (?'number'.*)"
|
|
|
|
|
Good Morning,
Please,
Is there a limit memory on the Windows to an application c#?
Ex: I have a program that carry different informations and that information are equals 2 GB for example
but when I go to do other process I can't do because it's give me Exception System.out.of.memory
how can I change this limit?
thanks
William
|
|
|
|
|
Not enough information.
How much memory is in the machine? Which version of Windows are you running? What code is throwing this exception? How big is the object you're allocating?
Under .NET, OutOfMemory exceptions cover a lot of things, some of which have nothing to do with running out of memory.
Also, no single object in .NET can be larger than 2GB. So, if you're trying to allocate say, an array of integers greater than 512 million elements, it's going to fail.
|
|
|
|
|
I'm using 8GB of Memory Ram, Windows 7 Professional 64 bits. Virtual Memory 6144 MB.
I carry a HashTable With 5 000 000 of records, this equivalent 2GB, but when I go to create other array of 25000 positions give me System out of memory exception.
If I stop the code in this section and instantiate the array in another application works perfect, so I have memory on the machine, so I see that the problem is the limitation of each application
thanks
|
|
|
|
|
Three thoughts:
1. is your app running in x-64 mode? how did you build it: x-86, x-64, or "Any CPU"?
2. could it be a fragmentation problem: objects larger than 80KB go in the Large Object Heap, which never gets compacted, hence could fragment when many different sized objects get allocated and freed in random order.
3. do you really need/want that big a hash table, wouldn't a database be more appropriate? or a completely different algorithm? (we don't know what it is your app is doing...)
|
|
|
|
|
X86, I use hash because i need fast performance, this informations already has a database.
thanks
|
|
|
|
|
If you aren't using any components that force you to keep building for x86, then go for x-64 (or "Any CPU"), and take advantage of the huge address space it offers. Mind you, each process must be homogeneous, you can't mix x86 and x-64 code in one build.
|
|
|
|
|
On top of what OriginalGriff said, it also depends on what you're doing. If you're resizing the HashTable to get to this point, you've fragmented the Large Object Heap. This will give you a problem. The Large Object Heap is never defragmented (for performance reasons).
So, if you started with a small(ish) HashTable, then exand it to accomodate more entries, you're actuall creating a new HashTable object with greater capacity, copying the references in old object to the new one, then destroying the old HashTable. Do this enough and you'll end up fragmenting the Large Object Heap to the point where you've got, say 5GB of memory available, but no free blocks of memory big enough to hold your new expanded HashTable all in one shot. There is no way to force a defrag of the Large Object Heap.
To get minimize this, try specifying the expected capacity of the HashTable when you create an instance of it.
|
|
|
|
|
There is no limit of 2GB for all information in .NET - but there is a limit of 2GB for any one object in .NET
What that means is that each object you create must be less than 2GB - you can have an array of 536,870,912 strings, each string of which can be 1GB in size, but you cannot have an array of 536,870,913 strings (assuming each reference is 32 bits, that would take teh total size of the array over 2GB - for 64 bit references the size is halved).
This doesn't mean that you won't get "out of memory" errors - it depends on how much virtual memory is available to .NET and your system in general, and you may run out of memory if the garbage collector can't free up a big enough chunk to fill a request.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
william ormundo wrote: but when I go to do other process I can't do because it's give me Exception
System.out.of.memory
Only way I can see that happening is if you have turned off virtual memory. And that has nothing to do with C#, it is an OS configuration issue.
|
|
|
|
|
I have a grid with 3 defined columns. Is there a way to divide column 1 into 3 grid rows without affecting the other 2 columns? I've tried defining RowDefinitions, but it spans all 3 columns. I don't want that. I only want it to affect the 1 column.
|
|
|
|
|
Sutton Mehaffey wrote: affecting the other 2
No
Sutton Mehaffey wrote: I don't want that
Then put another grid with 3 rows in column one.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|