0
我想从App_Data文件夹的实习txt文件中获取一个ArrayList。如何从App_Data的实习txt文件中获取ArrayList?
我在我的ASP.NET应用程序App_Data文件夹机智文件此内容如何:
P1
AS5050
GMS4010
GMS4020
GMS4030
GMS4030A
gateway
view_only
AS5050
,我想这个名单中ArraList。
我想从App_Data文件夹的实习txt文件中获取一个ArrayList。如何从App_Data的实习txt文件中获取ArrayList?
我在我的ASP.NET应用程序App_Data文件夹机智文件此内容如何:
P1
AS5050
GMS4010
GMS4020
GMS4030
GMS4030A
gateway
view_only
AS5050
,我想这个名单中ArraList。
var result = new ArrayList(File.ReadAllLines(pathToYourfile));
但是......为什么一个ArrayList
?通用名单在2013年会更好!
试试这个
ArrayList al = new ArrayList(File.ReadAllLines(path));
,但我会强烈建议List<T>
超过ArrayList
除非你使用.NET 1.0或1.1
List<string> list = new List<string>(File.ReadAllLines(path));
你尝试过什么? –
如果此数据P1 AS5050与\ r \ n分隔符分隔,则File.ReadAllLines将为您提供字符串ArrayList – dbw
不要再使用'ArrayList'。它属于过去C#没有_generics_的日子。改为使用'List'。 –