判断文件路径:
string Direpath1 = "INI";
string Filepath1 = "INI/system.ini";
if (!Directory.Exists(Direpath1))
{
Directory.CreateDirectory(Direpath1);
}
else
{
if (!File.Exists(Filepath1))
{
File.Create(Filepath1);
}
else
{
GetServer();
}
}
读取文件:
string Filepath="List/List.txt";
using (StreamReader sr = new StreamReader(Filepath))
{
String line;
while ((line = sr.ReadLine()) != null)
{
this.comboBox1.Items.Clear();
for(int i=0;i<line.Length/10;i++)
{
this.comboBox1.Items.Add(line.ToString().Substring(10*i,10).Trim());
}
}
sr.Close();
}