|
I am not surprised that the code takes a lot of time to run. You are creating one or two strings for every character you read, so to process a 500 MB file, you will have created about 1000 million string objects.
If you want to remove all line breaks and put line breaks before the keywork, why not simply:
string line;
string newLineMatchWord = "\r\n" + matchWord;
while ((line = inputReader.ReadLine()) != null) {
outputWriter.Write(line.Replace(matchWord, newLineMatchWord));
}
The Replace method returns a reference to the same string if no change was made, so it will only create a new string for lines that actually contain the keyword.
If the file can start with the keyword, you have to add some code to handle that before the loop. As this occurs only once, it should definitely be handled in separate code before the loop, and not inside the loop.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thankyou very much for the great reply!!!! the process was completed in just a bit less than 20 minutes on the same 35 GB file!!! Thanks
|
|
|
|
|
Nice. It's not every day you see a 20000% performance improvement.
---
single minded; short sighted; long gone;
|
|
|
|
|
Good job, Guffa, but there are to much zeros in your improvement calculation.
|
|
|
|
|
Sorry, % did the trick.
|
|
|
|
|
hi guys ,, i got some problem , i have a windows application in C# which contains some win forms,
but in the properties of this project i dont see any object to make it startup object,,
my forms are not seen in startup object drop down in the project properties > application tag >
- startup object drop down.
thanks in advance
hello
|
|
|
|
|
If your using VS2005 look at the program.cs file it contains something like the following;
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
If you look at the Run statement you you'll see here that I'm running form Form1 replace this with the name of the form you want to run at startup.
Prior to VS2005 each form that is elligible for startup will have just the run statement in Main
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
Hope this helps
Mike
You can do anything you want but you pay for everything you do!
|
|
|
|
|
Hello friends need help here..
Before this I have learn to create password validating form.Which is user have to key in password to enter another form. The password is default that have set in the coding.Now I need help how to connect to MY Sql database from C# from and compare the password that already I set in MY Sql database,table name Security and Field name password and the password is "ABCD".I dont know how to use SQL server 2005.
Below are the coding for the first form that validate to enter to form2.
//////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace cubaan1
{
public partial class Form1 : Form
{
Form2 form1 = new Form2();
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox1.PasswordChar = '*'; //Masking Char
textBox1.MaxLength = 14;//Max Length is 14
}
private void button1_Click(object sender, EventArgs e)
{
string strDefaultPassword = "security"; //Keep the default password
string strEnteredPassword = textBox1.Text;
if (strEnteredPassword == strDefaultPassword)
{
this.Hide();
form1.ShowDialog();
}
else
{
MessageBox.Show("Wrong password entered");
this.Close();
}
}
}
}
//////////////////////////////////////////////////////////
How to change this to connect to MY Sql Database and compare the password from the database.
Tq in advance......
|
|
|
|
|
CLASSES:student PROPERTIES :string name,string grade,string studentid,string surname METHODS:Add(string lessonCode, int point),grade showGrades(string lessonCode)
CLASS:grade PROPERTIES:String lessonCode,int point METHODS:
CLASS:reg PROPERTIES:int NumberOfRegs METHODS:AddStudent(student stu),RemoveStudent(string studentid),student ShowStudent(string studentid)
these are the classes,properties and methods that i have to use...
*students names,surnames,studentid and grades will be stored
*if any of the fields name,surname or grades if blank the registration wont be done
*for every student grades can be added
*studentid cant be changed,we can see the number of students,and we can call the students by their studentid
THATs all i need..i tried so hard but coludnt find a solution..
THX for your helps
|
|
|
|
|
Please don't start multiple threads on the same subject.
There is a modify link on your original post if you need to change your post.
Personally, I don't see that this post is any better than the last.
Please read my relpy to your original message.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
Make a start on your homework, when you get stuck we'll help you. But we won't do your homework for you. It would be unfair on you, even although by helping you with your homework you get the answer without learning anything it makes my job more secure.
So, some hints to get you started.
You have been given a list of classes, their properties and methods. Those are stubs that you can start writing. Then you just have to fill in the blanks.
|
|
|
|
|
yvzhn! this is Professor Ulhas from ur university.
when I saw u posted ur homeworx on the cpian web sights, i knew who u were. I told teh students never ever to post homoworks on the csexian webpags. now i see your failings i must felunks you in the highest orders. i have a doubt about your future life as soon i must curse you wit shiva devils for ur cheatings. infiinite melancholy! here is ur cursings!
vil humo ∑ﮗ shivna bar shiva ₣♂ un ulum ☺Ҝ♠ж dar niftu! ∑ ۞
sad curses
Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas
|
|
|
|
|
CLASSES PROPERTIES METHODS
student string Name grade Add(string lessonCode, int point)
grade ShowNotes(string lessonCode)
string studentid
grade [] grades
string Surname
grade String lessonCode
int Point
reg int NumberOfRegs AddStudent(student stu)
RemoveStudent(string studentid)
student ShowStudent(string studentid)
these are the classes,properties and methods that i have to use...
*students names,surnames,studentid and grades will be stored
*if any of the fields name,surname or grades if blank the registration wont be done
*for every student grades can be added
*studentid cant be changed,we can see the number of students,and we can call the students by their studentid
THATs all i need..i tried so hard but coludnt find a solution..
THX for your helps
|
|
|
|
|
|
If you really tried so hard, then you should be able to present at least the tiniest little bit of input from yourself, and not just pasting in the homework assignment.
There are a lot of people here that can give you useful hints, but for that you have to present what you have done, and where you are stuck.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello! I've made a animation of ball, flying on the form, from the edge to edge. But i've put a PictureBox,and the ball isn't seen anymore. It is flying in the backwards of my picttureBox. I've tryed to BringToTheBack the pictureBox, but it is not working. What should i do?
One nation - underground
|
|
|
|
|
AFAIK you can do nothing, since the PictureBox is a Control of the Form and you cannot overwrite its area when drawing inside OnPaint. As workarounds you can:
(1) use a another PictureBox to represent the bouncing ball.
or
(2) Build a customized PictureBox (deriving from the original one), and override the paint method to make it aware of the overlapping ball.
hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hello Dear Friends !!!
I have a window with a button, which calls other window. There i call function
public void ShowOneInListView(ListView L, string N, string M, string S)<br />
{<br />
ListViewItem item = new ListViewItem(N);<br />
item.SubItems.Add(M);<br />
item.SubItems.Add(S);<br />
item.ForeColor = Color.Violet;<br />
L.Items.Add(item);<br />
}
which uses the listview(L) from another form. How can i access that listview, or that form ?
-- modified at 5:58 Sunday 1st April, 2007
One nation - underground
|
|
|
|
|
|
Thanks !!!!!!!!!!!!!!!!!
One nation - underground
|
|
|
|
|
Sir, can I have a doubt that If C# does not support Pointers then how C# is able to Support Runtime Polymorphism ? Pls help me in understandig the concepts better.
Thanking You
Fly Like An Eagle With MIGHTY POWER.
|
|
|
|
|
|
You should've been here yesterday
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
I created a small Windows form using C# that add and remove text from a file. To run the Windows form a user just need to click on the "Enablelog.exe." The "Enablelog.exe" only has a name attached to it(Enablelog.exe) which make it looks very plain. Can some one show me how I can add an image to it so that it will be on the "Enablelog.exe" and make it looks more professional. I am using Visual Studio 2005.
Any help will greatly be appreciated,
Donjuanwu
|
|
|
|
|
Try using an Icon
If you created the project with Visual Studio then you should have a "app.ico" or something like this into the project files
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|