这些解决方案都不适合我……即使我可以更改 CurrentCulture,我仍然收到错误“字段分隔符 = 十进制分隔符”。
但是因为我很笨,我忘了正确设置schema.ini。这是我得到的:
private void writeSchema()
{
try
{
FileStream fsOutput = new FileStream(this.dirCSV + "\\schema.ini", FileMode.Create, FileAccess.Write);
StreamWriter srOutput = new StreamWriter(fsOutput);
string s1, s2, s3, s4, s5, s6, s7, s8;
s1 = "[" + this.FileNevCSV + "]";
s2 = "ColNameHeader=" + chkFirstRowColumnNames.Checked.ToString();
s3 = "Format=" + this.strFormat;
s4 = "MaxScanRows=25";
s5 = "CharacterSet=" + this.strEncoding;
s6 = "DecimalSymbol=.";
s7 = "CurrencyDecimalSymbol=.";
srOutput.WriteLine(s1.ToString() + "\r\n" + s2.ToString() + "\r\n" + s3.ToString() + "\r\n" + s4.ToString() + "\r\n" + s5.ToString() + "\r\n" + s6.ToString() + "\r\n" + s7.ToString());
srOutput.Close();
fsOutput.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "writeSchema");
}
finally
{ }
}
这让该死的东西工作得很好。感谢大家的帮助!