Problem While Writing To A Text File
-
Hi all, Am replacing a particular string with another string of a text file dynamically. but while doing this am putting them to a richtextbox also. the contents of this text file contains lot of HTML tags. right now am facing alignment problems. here is the code i have for replacing can some one help me with better solutions than mine
<------------------CODE---------------------> public void ConvertFile(string Pathstring) { bool change = false; StreamReader re = File.OpenText(Pathstring); string test = ""; string input = null; string fileName = Pathstring; while ((input = re.ReadLine()) != null) { if (input.Contains("XXX-XX")) { change = true; } if (change == true) { if (input.Contains(".jpg")) { if (test.Contains("XXX-XX")) { test = test.Replace("XXX-XX", GetFilename((input))); } } } test += input+"\r\n"; } re.Close(); richTextBox1.Text = test; } <------------------END OF CODE--------------------->
-
Hi all, Am replacing a particular string with another string of a text file dynamically. but while doing this am putting them to a richtextbox also. the contents of this text file contains lot of HTML tags. right now am facing alignment problems. here is the code i have for replacing can some one help me with better solutions than mine
<------------------CODE---------------------> public void ConvertFile(string Pathstring) { bool change = false; StreamReader re = File.OpenText(Pathstring); string test = ""; string input = null; string fileName = Pathstring; while ((input = re.ReadLine()) != null) { if (input.Contains("XXX-XX")) { change = true; } if (change == true) { if (input.Contains(".jpg")) { if (test.Contains("XXX-XX")) { test = test.Replace("XXX-XX", GetFilename((input))); } } } test += input+"\r\n"; } re.Close(); richTextBox1.Text = test; } <------------------END OF CODE--------------------->
I see you've taken none of the advice you were given the other day ?
Christian Graus - Microsoft MVP - C++ "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 )
-
I see you've taken none of the advice you were given the other day ?
Christian Graus - Microsoft MVP - C++ "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 )
Yes if i give File.WriteAll, i tried but it was not working, cause its taking last file name and writing it on places of XXX-XX.
-
Yes if i give File.WriteAll, i tried but it was not working, cause its taking last file name and writing it on places of XXX-XX.
I don't follow you ? if you create a string [] by calling File.ReadAllLines, you can iterate over the lines and call your method to get the filename, and then call File.WriteAllLines. Putting it in a richtextbox is superfluous, unless you want the user to hand edit the file. Even then, a text control makes more sense, b/c you don't have rich text to start with, do you ?
Christian Graus - Microsoft MVP - C++ "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 )