|
First, please tell me they are not called that...
The easiest way to do this is to make your forms controls within the one form, and change which one is visible. If Form2 disappears when Form3 shows, that's the best way to approach that, in general. The other way to do it, is to just hide Form2, instead of destroying it.
The controls approach is nicer.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: ForumC#
Subject:Re: Windows Forms
Sender:Christian Graus
Date:9:35 27 Mar '07
First, please tell me they are not called that...
|
|
|
|
|
Hello,
You could hold the Form2 instance in memory (Hide), instaed of disposing (Close) every time you change to ann other form.
All the best,
Martin
|
|
|
|
|
Hello All
i am trying to read a large txt files -may 1 GB-, which coze my program to hang, and i need to know if there are techniques that make this without hang and do it faster
if you know something can help. please tell me.
|
|
|
|
|
The best thing is to avoid such files. You *can* read a file a line at a time, but I'm not sure if it loads in to memory anyhow when you do that. I'd hope not. What code are you using right now ? What is in the files ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi
You could consider using a backgroundworker to read the file, while showing a "loading" sign or something..
basically something like:
private void getTextFileWorker_DoWork(object sender, DoWorkEventArgs e)
{
//start to read the file, show loading sign...
while(morelinesinfile)
{
this.Invoke(new AddValueDelegate(AddValue), new object[] { valueFromFile });
}
}
private void AddValue(string valueFromFile)
{
//do something with the value, add it to a list...
}
private void getTextFileWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//finish up etc..hide sign..
}
best regards
HV
|
|
|
|
|
I suspect the real issue is that 1 GB of text will, on most computers, mean your RAM is full and you're using virtual memory.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
that is my code , and i had run it for a txt file its size is 423 MB, and i left my PC opened and in the mext day i found that it records about 10 hours and large number of lines about 500000 line and also i got an exception "OutOfMemoryException"
and i dont know much about "backgroundworker", if you know a complete example plz provid me by the link
StreamReader SR;
private void btnReadFile_Click(object sender, EventArgs e)
{
DateTime DT= DateTime.Now;
TimeSpan T = new TimeSpan(DT.Day, DT.Hour, DT.Minute, DT.Second);
if (SR != null)
{
while (!SR.EndOfStream)
{
try
{
string line = SR.ReadLine();
txtFileContent.AppendText(line);
txtFileContent.AppendText("\n");
txtFileContent.AppendText("\r");
int count = Convert.ToInt32(labNumOfLines.Text);
count++;
labNumOfLines.Text = count.ToString();
DateTime tempTime = DateTime.Now;
TimeSpan T2 = new TimeSpan(tempTime.Day, tempTime.Hour, tempTime.Minute, tempTime.Second);
T2=T2.Subtract(T);
labTime.Text = T2.ToString();
this.Refresh();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
|
|
|
|
|
Is txtFileContent a string or a StringBuilder ? IF the former replacing it with the latter will see a massive performance boost. A string is immutable, which means each time you do txtFileContent.AppendText(line); you're creating a new string and copying the old one to it. For normal use immutable strings allow certain optimizations that result in faster code, but when building a really large string they absolutely murder performance. IF you;re using a string for each line of your file you're copying everything read so far three times. And absolutely thrashing the GC in the process.
--
CleaKO The sad part about this instance is that none of the users ever said anything [about the problem].
Pete O`Hanlon Doesn't that just tell you everything you need to know about users?
|
|
|
|
|
txtFileContent is a textBox
|
|
|
|
|
That almost certainly uses a string internally. Load the entire thing into a stringbuilder first and then copy when complete. Even then I seriously doubt the tb is capable of handling that large a string in a managable fashion.
--
CleaKO The sad part about this instance is that none of the users ever said anything [about the problem].
Pete O`Hanlon Doesn't that just tell you everything you need to know about users?
|
|
|
|
|
Also if the file is order or can be ordered access it in that manner. Ie, Binary Searches, index based searches, etc. I have worked with several multi gig files in the past and that is the only hope.
File Not Found
|
|
|
|
|
Hi all,
I am working on a school project in c#. It was going good so far but now I have to convert a Motorola S-record file to a Binary file. I know the layout of the S-record file. But I have no idea how to convert this to a binary file (using c#). I hope anyone can help me with this problem.
I have found some anwsers on the internet but the source code didn't fit the c# context.
|
|
|
|
|
-=gix=- wrote: I know the layout of the S-record file. But I have no idea how to convert this to a binary file
What part are you stuck on? You know the format of the input file, do you know how to read it? What is the format of the binary file? (You didn't mention that) And once you know the format of the output, do you know how to write that?
There is also the translation aspect, do things need to be re-ordered between input and output? Or is the translation a direct text based data to binary based data?
|
|
|
|
|
I know how to read the S-record, but the problem is that I have no idea how a binary file looks like (the format). If I know this, I will be able to write it.
further information:
The binary file is used for a MCU (Micro Controller Unit) on an ARM processorboard.
|
|
|
|
|
-=gix=- wrote: but the problem is that I have no idea how a binary file looks like (the format).
Then you need to find out the format before we can help. There are thousands, if not millions, of possible binary formats.
|
|
|
|
|
I did some searching and I found out that I have to convert the data string from the S-record (in hex) to a data string in binary and then write it to the memory and a file.
|
|
|
|
|
Hi,
I have a windows application in which the user selects a folder. I want to share this folder and make it availabe to all other users on the network with full rights. Can any body tell me how to do it? I want it done the .Net way not using the Calc.exe or System.Management or any other crude way?
I have googled very much but no +ve response.
Waiting for your reply...
Regards,
Wasif Ehsan.
|
|
|
|
|
How to get the text that user keyin in textbox in other window form to another form.Like from form1 to form2.
The text will increase like ++1.
How can the text apear/console in form2 one by one.
And have a button in form2 to delete which text user want to delete.
Tq very much. Need help here.
|
|
|
|
|
krajah1984 wrote: How to get the text that user keyin in textbox in other window form to another form.Like from form1 to form2.
You could read this article on passing values between forms[^]
|
|
|
|
|
How to compare the password we have keyin in (notepad/simple database) with user keyin in the textbox in window form.
Another form that have two textbox:
One for user key in old password
Another for user key in new password
If user klick button it will change the password in the notepad to new password that user key in second text box.
Need help here.....
|
|
|
|
|
Hi,
You can consider the password as a normal text. Means you can compare the passwords typed in two textbox as same as how you use to check plain text typed in two textbox.
if (textBox1.Text == textBox2.Text)
{
MessageBox.Show("hello");
}
Thanks and Regards
Balaji
|
|
|
|
|
Question 1:(form1)
How to compare my default password that i save in notepad.
How to compare with the password that user input in text box.How to call the password that have key in the notepad.
Question 2:
In another form I make to textbox one for user input old password and another textbox for user input new password.The new old password will be replace by the new password in the notepad.After this it will compare with the new password in the form1
|
|
|
|
|
Can you tell me what all will be in your notepad. Will it contain only the password ?
|
|
|
|
|