c# problems with special characters using replace

outlawriderz

New Member
My file index.xml (my index.xml file) , contain file names of extension .xmf .xaf .xpfusing xmlDocument, I have obtained the names of these files. Now my intention is to rename each of those files for a random name. I have already defined a new name for each file as shown: My gui with names to renameRename desire, with the names of the right list:
  • 01_06.xaf to ---> c1bf090cd1.xaf
  • 01_06.xpf to ---> 2060f7bc60.xpf
  • 01.xmf to to ---> d3b1cb4f3128.xmf
then I created a function with three parameters, which receives[*]the path file index.xml [*]Lb1 (original name)[*]Lb2 (new names)and by \[code\]GetXmlString function()\[/code\], raised the index.xml file to a variable String. Then try to rename using Replace.\[code\]public void renameNames (String indexXML, lb1 ListBox, ListBox lb2){ lbString1 string; lbString2 string; stringINDEX string = GetXmlString (indexXML); for (int i = 0; i <lb1.Items.Count; + + i) { lb1.Items lbString1 = . ToString (); lb2.Items lbString2 = . ToString (); stringINDEX = stringINDEX.Replace (lbString1, lbString2); } File.WriteAllText (indexXML, stringINDEX); }\[/code\]and to execute the function to rename the extensions.Xaf .Xpf .Xmf\[code\]renameNames (pathINDEXXML, listBox3, listBox4) // rename. xaf filesrenameNames (pathINDEXXML, listBox5, listBox6) // rename. xpf filesrenameNames (pathINDEXXML, listBox7, listBox8) // rename. XMF files\[/code\]manages to change the names but unexpectedly, I get these results for example.\[code\]a251a97c113e7e8c6d61befe76fa114d3cb93bb1627a7c189221.xmf (incorrect)3be62912313b94f3faa212.xmf (incorrect)b5a3b096e18550143e8214.xmf (incorrect)89010234220.xmf (correct)\[/code\]
H2czt.jpg
some files are renamed correctly, and others get a long name. I think this happens because the names contain special characters-> "." And "_"how I can make this change of name, any help please, I have days without a remedy.
 
Back
Top