Txt output difference in Excel and C#

We have an old excel spreadsheet with vb macros that outputs a text/xml file. This text is used as input to another program. I've written a C#/.net web application that outputs the same text/xml file. When this file is fed to the other program, it crashes. The files are identical to the naked eye, so to speak, but there must be some formatting difference.
What am I looking for?
Who is Participating?
gplanaConnect With a Mentor Commented:
You can try using some tool like "WinHex" to examine the file at low level and see the differences. Also it could be an encoding character problem (maybe one is using UTF-8 and another is using Latin-1), or it could be caused by some invisible characters like spaces, tabs, line feeds, carry returns, etc...

You can also consider using a tool like windiff to compare both files.

Hope it helps.
allelopathAuthor Commented:
I should have been more explicit ... They look identical in a hex editor, e.g. there is 0D 0A at the end of each line. So the difference is encoding. Is there a default encoding when writing out using an excel vb macro?
If they are identical in a hex editor, then the problem couldn't be the file because both files have the same content. Try to rename a file to the other and see what happens (maybe the problem is the name of the file?)
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

allelopathAuthor Commented:
I take back what I said. The files are not different. The file I am generating in C# has 3 characters at the beginning:
EF BB BF      
which apparently specifies UTF-8. So I can do this with XmlWriterSettings:
this.settings.Encoding = Encoding.ASCII;

Open in new window

Miguel OzConnect With a Mentor Software EngineerCommented:
Can you post the two files?  or You can use a diff tool like beyond compare to send the differences only, especially at the top of your files.
If the contents are the same usually the difference is the encoding you need to find out the encoding of each file by using a program like Notepad++, just open the file and look for the file properties. Once you have the encoding of your original file then you just need to have the same encoding for your .net generated file.

Another option is to change the other program (that consumes your xml) to handle xml with utf-8 encoding.
allelopathAuthor Commented:
Note that my last comment is the answer.

I tried to accept it as the answer but it looks like there is a bug in EE.
When I check the Your comment box and the Best Solution radio button for my last comment, as well as selecting the 2 posts by the experts (each defaulting to 250pts). I cannot assign points to my comment because there is no point box there and so when I submit, it won't complete saying that each accepted answer must have points.

Chrome Version 27.0.1453.116 m
All Courses

From novice to tech pro — start learning today.