|
我这断代码是读取本地TXT文件内容,我想修改为读取资源里的资源名为 userdd 的内容 该如何该是好,谢谢帮助
public bool LoadHostFile()
{
string filename = HOST_FILENAME;
string absFilePath = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, filename);
if (System.IO.File.Exists(absFilePath)) //文件是否存在
{
try
{
using (System.IO.StreamReader stream = System.IO.File.OpenText(absFilePath)) //
{
while (true)
{
string line = stream.ReadLine();
if (line == null)
break;
if (line.Length > 0 && line.StartsWith("#"))
continue;
string[] parts = line.Split(new char[] { ' ', '\t', }, 2, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length < 2)
continue;
AddHost(parts[0], parts[1]);
}
}
return true;
}
catch
{
return false;
}
}
return false;
}
}
}
|
|