FileStream:文件流
用于打开,存储文件
using(filestream fs=new
filestream(path,filemode.openorcreate,fileacess.readwrite))
{
byte[] bytxt=new byte[]; ---字节流
char[] filetxt=new char[]; ---字符流
读取字节流
fs.reader(bytxt,0,bytxt.length)
字节流转码
decoder de=encoding.utf-8.default();
解码字节流转换成字符流
de.getchars(bytxt,0,bytxt.length,filetxt);
}
读写文件操作
char[] chart=new char[1024]; ---定义要读取的文件大小
int length=null;
FileRed()
string path="c/code/1.txt "
//判断是否有这个文件
file.exist(path);
streamReader fr=new stremReader(path);
if(length=fs.read(chart)!=-1)
{
streamWriter fw=new streamwrite(path,true);
char[] cha=new char[1024];
fw.write(cha);
fw.flush();
}