Domanda

I do have a .dll file and I'am trying to read the text file which is in it to my GridControl. The text file is like this (with more rows...):

1111    Maximum     SomethingA
1222    Minimum     SomethingB
1333    MediumS     SomethingC

My code:

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: I used to read the .txt file just fine using File.ReadAllLines(Path.Combine(Enviroment....)

È stato utile?

Soluzione

I'am trying to read the text file which is in it

If the text file is loaded into the resources as a string, you can't use File.ReadAllLines. Instead, just read the string and split it:

string[] strArrays15 = resourcemanager.GetString("GISS").Split('\n');
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top