首页 > 代码库 > C#文件读写参考

C#文件读写参考

string s = "";
string[] files = Directory.GetFiles(@"E:\u3d_warcraft\logic\logic\Battle\Skill");
foreach (string file in files)
{
s = file.Split(new char[]{‘\\‘})[6].Split(new char[]{‘.‘})[0];

FileStream fs = new FileStream(@"E:\u3d_warcraft\logic\logic\bin\Debug\Xml\skill\_SkillCommon.xml", FileMode.Open);

StreamReader m_streamReader = new StreamReader(fs);

m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
string strLine = m_streamReader.ReadLine();
bool T = false;
do
{
string[] split = strLine.Split(‘=‘);
if (strLine.Contains(s))
{
T = true;
}
strLine = m_streamReader.ReadLine();

} while (strLine != null && strLine != "");
if (!T)
{

MessageBox.Show(s);
}
m_streamReader.Close();
m_streamReader.Dispose();
fs.Close();
fs.Dispose();
}

C#文件读写参考