Showing posts with label basically. Show all posts
Showing posts with label basically. Show all posts

Saturday, March 24, 2012

Strange Errors

Im having a problem with one of my pages. Basically what i have is a page where someone can upload files and its all working ok. I also a have option for them to delete files, if they click this they are brought to a separate page to confirm the delete. It all works find for the first file i delete but when i try to do it again, my directory.delete function works but my database delete doesnt ? any idea's?Its ok figured it out, had the parameters in the wrong order !
Deleting a directory in asp.net is tricky. Afetr you delete a directorythe application will restart and u will looase all ur session dat if uare using in-proc session. Here is a link explaining that
http://vikramlakhotia.com/Post.aspx?postID=6

Thursday, March 22, 2012

Strange issue with Replace() on a stringbuider

I am having a problem with a search/replace function I wrote. It doesnt seem to match anything if it contains an upper case char. Basically, if what I am trying to replace contains an upper case character, then the Replace() function will not find it. It will find all identical instances with lower case chars, tho.

source : abcdeABCDE
replace : d,! -or- D!
result : abc!eABCDE

oReplace is a StringDictionary,
textboxes are all RichTextBoxen

I have tried with strings, stringbuilders, adding differenty ways, calling .ToString() on everyhing, adding to the SB as char array (.ToCharArray)!


for (i = 0; i <= iLines; i++) {
sLine = this.txtReplace.Lines[i].ToString();
arrLine = sLine.Split(new char[]{','},2);
if (arrLine.GetUpperBound(0) != 1) {
this.txtResult.Text = "Bad replace line detected : " + sLine;
return;
} else {
if (oReplace.ContainsKey(arrLine[0])) {
this.txtResult.Text = "duplicate replace specified : " + arrLine[0];
return;
} else {
oReplace.Add(arrLine[0].ToString(),arrLine[1].ToString());
}
}
}
StringBuilder sb = new StringBuilder();

sb.Append(this.txtSource.Text.ToString());
foreach (string sOrig in oReplace.Keys) {
sOld = sOrig.ToString();
sNew = oReplace[sOld].ToString();
this.txtResult.Text += "[" + sOrig + "][" + sNew + "]" + System.Environment.NewLine;
sb = sb.Replace(sOld.ToString(),sNew.ToString());
}

this.txtResult.Text += sb.ToString();

Can you give the exact contents of the dictionary (keys and values)?