Open file in C#

Associate
Joined
7 Oct 2005
Posts
609
Hey Guys,

I'm wondering how to open an XCR file (Basically it is an XML file) as a txt file in c# so I can do a find and replace on "&" to &. Can anyone help? I have did some research on google but it only seems to be example of opening an txt file.

I know to use something like the following:

System.IO.File("file path")??

Appreciate any help!

Murzo
 
File.ReadAllText()

What you're doing is very hacky though and liable to introduce errors into the XML.

E.g. what if the file already uses & ? Your simple string replacer is going to turn that into &
 
I have a program that I'm trying to modify which basically when an "&" is the description field it throws an error, take out the & and it works perfect. I know its got something to do with the XML file. So I need to go throught that file and change & to & according to my colleague in work, so that it will allow for the use of &.
 
so the problem is in the saving to the file. you should have been looking at fixing the saving of (non-compliant ?) xml files, rather than fixing the side-effects.
 
Back
Top Bottom