using System;
using System.IO;
namespace CSharp类库集合
{
/// <summary>
/// 操作文本文件 的摘要说明。
/// </summary>
public class 操作文本文件
{
public 操作文本文件()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public void readFile(string strPath,string strValue)
{
FileStream fsInfo = new FileStream( strPath, FileMode.Open, FileAccess.Read );
StreamReader srInfo = new StreamReader( fsInfo, System.Text. Encoding.GetEncoding( "GB2312" ) );
srInfo.BaseStream.Seek( 0, SeekOrigin.Begin );
strValue = " ";
string strLine = srInfo.ReadToEnd();
while( strLine != null )
{
strValue += strLine + "/n";
strLine = srInfo.ReadLine();
}
srInfo.Close();
}
public void writeFile(string strPath,string strValue)
{
FileStream fsInfo = new FileStream( strPath, FileMode.OpenOrCreate, FileAccess.Write );
StreamWriter swInfo = new StreamWriter( fsInfo );
swInfo.Flush();
swInfo.BaseStream.Seek( 0, SeekOrigin.Begin );
swInfo.Write( strValue );
swInfo.Flush();
swInfo.Close();
}
}
}