C#判断txt文件中某个字符串是否存在的函数
2009-01-17 10:30
441 查看
今天整理代码发现注释掉的一部分,扔了有点可惜,就放上来了
private bool IsExistError(string strTxtName)
{
取文件的路径
bool isExist=false;
string strError="NativeError ";
int nLength=strError.Length;
StreamReader sr=new StreamReader(strFilePath+strTxtName);
string strLine=sr.ReadToEnd();
if(strLine.Length>=nLength)
{
for(int i=0;i<strLine.Length-nLength;i++)
{
if(strLine.Substring(i,nLength)==strError)
{
isExist=true;
break;
}
}
}
else
{
isExist=false;
}
sr.Close();
return isExist;
}
private bool IsExistError(string strTxtName)
{
取文件的路径
bool isExist=false;
string strError="NativeError ";
int nLength=strError.Length;
StreamReader sr=new StreamReader(strFilePath+strTxtName);
string strLine=sr.ReadToEnd();
if(strLine.Length>=nLength)
{
for(int i=0;i<strLine.Length-nLength;i++)
{
if(strLine.Substring(i,nLength)==strError)
{
isExist=true;
break;
}
}
}
else
{
isExist=false;
}
sr.Close();
return isExist;
}
相关文章推荐
- 通过文件锁实现,程序开始运行时,先判断文件是否存在,若存在则表明该程序已经在运行了,如果不存在就用open函数创建该文件,程序退出时关闭文件并删除文件
- C#中判断文件或文件夹是否存在
- 关于判断文件是否存在最高效的函数(转)
- C#判断文件路径是否存在或者判断文件是否存在的方法
- configure文件中判断某函数或库是否存在的一个方法
- C#判断硬盘上的文件是否存在方法
- C#判断文件及文件夹是否存在并创建
- C# 判断文件夹和文件是否存在的方法
- C#判断本地文件,网络文件是否存在是否存在
- C# 判断文件和文件夹是否存在并创建
- C#判断远程文件是否存在
- Shell脚本执行hive语句 | hive以日期建立分区表 | linux schedule程序 | sed替换文件字符串 | shell判断hdfs文件目录是否存在
- C#之中的字符串替换方法以及判断是否存在特定子字符串
- paip.判断文件是否存在uapi python php java c#
- C#判断文件和文件夹是否存在 不存在则创建
- linux下的access()函数判断文件是否存在
- C# 判断远程文件是否存在
- Python判断一个文件中的字符串是否存在于另外一个文件中
- c# 判断指定文件是否存在的简单实现
- C# 判断文件是否存在 和 文件夹是否存在