【发布时间】:2014-03-22 01:51:33
【问题描述】:
我确实有一个 .dll 文件,我正在尝试将其中的文本文件读取到我的 GridControl 中。 文本文件是这样的(多行...):
1111 Maximum SomethingA
1222 Minimum SomethingB
1333 MediumS SomethingC
我的代码:
char[] chrArray10 = new char[1];
chrArray10[0] = '\t';
Assembly assembly = Assembly.LoadFile("C:/Users/PC-Me/documents/visual studio 2013/Projects/ClassLibrary1/ClassLibrary1/bin/Debug/MyDLL.dll");
System.Resources.ResourceManager resourcemanager = new System.Resources.ResourceManager("ClassLibrary1.Properties.Resources", assembly);
string[] strArrays15 = File.ReadAllLines(resourcemanager.GetString("GISS"));
string[] strArrays16 = strArrays15[0].Split(chrArray10);
DataTable dataTable5 = new DataTable();
string[] strArrays17 = strArrays16;
for (int s = 0; s < (int)strArrays17.Length; s++)
{
string str5 = strArrays17[s];
dataTable5.Columns.Add(str5, typeof(string), null);
}
for (int t = 1; t < (int)strArrays15.Length; t++)
{
char[] chrArray11 = new char[1];
chrArray11[0] = '\t';
dataTable5.Rows.Add(strArrays15[t].Split(chrArray11));
}
gridControl2.DataSource = dataTable5;
return;
PS:我曾经使用File.ReadAllLines(Path.Combine(Enviroment....)阅读.txt文件很好
【问题讨论】:
-
您遇到了什么问题?
-
有什么问题? 阅读错误信息。
-
你认为
File.ReadAllLines会做什么? -
您的问题到底是什么?您收到错误消息吗?顺便说一下,给你的变量起更有意义的名字。
-
很抱歉没有发布错误。它是法语的。 #Fixed by Reed Copsey answer:)
标签: c# file-io datagridview gridcontrol