9

I have the following CSV file that is used in my data-driven unit test:

File;expected
Resources.resx;default
Resources.de.resx;de
AttachmentDetail.ascx.it.resx;it
SomeOtherFile.rm-CH.resx;rm-CH

"File" and "expected" are the header. But if I want to get the "File"-column in the code like

TestContext.DataRow["File"].ToString();

I get the error

System.ArgumentException: Column 'File' does not belong to table ..

When I add the CSV file to an existing test-case over the test-method properties, it seems as if the "File"-column has some strange signs before its name, much like an encoding problem. But if I open the CSV file with Notepad, Notepad++ or even TextMate (on Mac) I don't see any such signs and I'm not able to get rid of them.

Can someone give me a suggestion about this problem?

Juri
  • 32,424
  • 20
  • 102
  • 136

2 Answers2

12

If you edit the CSV file in the VS2008 you can set the way the CSV file will be saved:

"File\Advanced Save Options..."

In the "Encoding:" drop down the default will be UTF-8. Change it to "Wester European (DOS) - Codepage 850". Leave the Line endings selection alone.

Doug Boone
  • 365
  • 1
  • 12
  • 2
    This worked for me. This probably should be marked as the answer. – Joel McBeth Feb 24 '12 at 19:07
  • Great tip, this worked for me. Spent about 2 hours stuggling with the ArgumentException error until I found this post. All my other CSV data files worked fine but 1 did not and this was the reason. Very odd problem. Not sure why it happened in the first place. – Jim Kennedy Feb 17 '14 at 20:30
0

What encoding is the file being saved?

From what I know, UTF-8 saved in windows notepad puts up some strange symbols in front of the file to know exactly what encoding was used when it didn't find any symbols that are needed for UTF8 (assuming everything is just plain ascii)

Did you edit the file using Notepad++ and saved it? I would try doing that and compare the results.

Gustavo Muenz
  • 9,278
  • 7
  • 40
  • 42
  • That was also my first assumption and so I did as you said and edited+saved the file with Notepad++...however with no result. I'm getting mad, it would be so simple, just these damn signs. There must be something wrong. – Juri Jul 10 '09 at 17:20