Hello planoie,
Let me explain about the Webpage use, The Datagrid being added to the Webpage is for different clients, each DataGrid contains infomation unique for that client only. Now instead of always having to manually adding new Datagrids to the Webpage as needed. I have written a FindnReplace Code to run and automatically add the new Datagrid as necessary, using certain (keyword) with the FindnReplace code. Now with 1-10 clients on the Webpage it works extremely fast and efficient. I noticed as the Webpage grows in size the efficiency starts to bog down...This is Not Good... So hence my dilemma. I was hoping for a some kind of solution to get the FindnReplace technique to somehow go directly to the (Keywords), Or Read from the Top of the Webpage. The (Keywords) I have been using are TextWords. Would it make any difference if I changed the Keywords to Somekind of Unique (Sysbols)=$$~~$$) instead ???
If only there were a way to keep the FindnReplace Code from having to read thru Everything - somehow to block it and only read what you want it to read. This is where my thoughts are. I'm not sure if this is possible??? Here is my Replace Code snipet. . . If you can think of Something that would be great. . .Thank You.
__________________________________________________ __________________________________________________ ___________________________________________
void btnReplace_Click(object sender, EventArgs e) {
txtReplace.Text = txtContents.Text;
txtFound.Text ="";
if(CheckEmpty())
{
DirectoryInfo DI= new DirectoryInfo(txtFolder.Text);
if(DI.Exists)
{
int FileCount=0;
lstFound.Items.Clear();
foreach(FileInfo FI in DI.GetFiles())
{
if(FI.Extension==txtFileExt.Text || txtFileExt.Text=="" ||txtFileExt.Text=="*.*")
{
try
{
StreamReader SR= new StreamReader(FI.OpenRead());
String s;
String temp="";
int pos=0;
s=SR.ReadLine();
while(s!=null)
{
temp=temp+s+"\r\n";
s=SR.ReadLine();
}
temp=temp.Substring(0,temp.Length-2);
SR.Close();
if(temp.IndexOf(txtFind.Text)>=0)
{
pos=temp.IndexOf(txtFind.Text);
//txtFound.Text =txtFound.Text +FI.Name + " Char:"+pos+System.Environment.NewLine;
lstFound.Items.Add(FI.Name + " Char:"+pos+System.Environment.NewLine);
//MessageBox.Show("temp:"+temp+ " "+"txtFind:"+txtFind.Text+" txtReplace:"+txtRepla ce.Text);
temp=temp.Replace(txtFind.Text,txtReplace.Text = txtContents.Text.Trim());
//MessageBox.Show("temp: "+temp);
FI.Delete();
StreamWriter SW= new StreamWriter(FI.OpenWrite());
SW.Write(temp);
SW.Close();
FileCount++;
}
}
catch(Exception)
{
MessageBoxShow.Text = ("Error opening file!");
}
}
} // Foreach Loop Ends Here
txtFound.Text =txtFound.Text + "Replace Completed Successfully..."+System.Environment.NewLine + "No of Occurences :" +FileCount;
} // IF Loop Ends Here
else
MessageBoxShow.Text = ("Please enter a valid directory path!");
}
|