利用io流进行文件读取和写入
来源:互联网 发布:linux cat和more 编辑:程序博客网 时间:2024/05/22 08:23
public void SaveFile(string path,string name,string information)
{
StreamWriter sw;
FileInfo t = new FileInfo(path+"//"+name);
if (!t.Exists)
{
sw = t.CreateText();
}
else
{
sw = t.AppendText();//打开文件
}
sw.WriteLine(information);
sw.Close();
sw.Dispose();
}
public ArrayList LoadFile(string path, string name)
{
StreamReader sr = null;
FileInfo t = new FileInfo(path + "//" + name);
if (t.Exists)
{
try
{
sr = File.OpenText(path + "//" + name);
}
catch (Exception exp)
{
Debug.Log("LoadFile 读取数据出错:" + exp);
return null;
}
string line;
ArrayList arraylist = new ArrayList();
while ((line = sr.ReadLine()) != null)
{
arraylist.Add(line);
}
sr.Close();
sr.Dispose();
return arraylist;
}
return null;
}
public void DeleteFile(string path,string name)
{
File.Delete(path+"//"+name);
}
{
StreamWriter sw;
FileInfo t = new FileInfo(path+"//"+name);
if (!t.Exists)
{
sw = t.CreateText();
}
else
{
sw = t.AppendText();//打开文件
}
sw.WriteLine(information);
sw.Close();
sw.Dispose();
}
public ArrayList LoadFile(string path, string name)
{
StreamReader sr = null;
FileInfo t = new FileInfo(path + "//" + name);
if (t.Exists)
{
try
{
sr = File.OpenText(path + "//" + name);
}
catch (Exception exp)
{
Debug.Log("LoadFile 读取数据出错:" + exp);
return null;
}
string line;
ArrayList arraylist = new ArrayList();
while ((line = sr.ReadLine()) != null)
{
arraylist.Add(line);
}
sr.Close();
sr.Dispose();
return arraylist;
}
return null;
}
public void DeleteFile(string path,string name)
{
File.Delete(path+"//"+name);
}
阅读全文
0 0
- 利用io流进行文件读取和写入
- java中IO流进行文件的创建和删除
- 使用IO流进行文件拷贝和文件夹拷贝
- 使用IO流进行文件的拷贝
- 【我的Java笔记】IO流_使用IO流进行文件的复制和粘贴
- 用IO流进行文件读写的封装工具类
- 使用Java IO 流进行文件的复制,复制成功,却打不开复制的文件
- 用缓冲流进行文件的复制
- .net 流——使用流进行文件复制
- c++的传递的二进制流进行文件上传操作
- Java中通过输入输出流进行文件的读写
- java-IO读取和写入
- Qt中文件写入和读取
- C++ 下文件的读取和写入
- Python中文件的读取和写入
- java中使用文件输入流和文件输出流进行文件读写的用例!
- IO学习(七)用字符流进行纯文本的读取和写出
- IO流对文件读取和写入
- 如何快速卸载VS2010
- 关于目录的小常识
- BMOB后端云
- Linux——自动安装脚本
- day11java基础
- 利用io流进行文件读取和写入
- poj 1011 Sticks DFS 剪枝
- 名称空间的使用
- ES6学习笔记
- 二叉树遍历算法实现
- @android:style/之Android系统自带样式
- SpringMVC 问题记录
- shiro+mybatis+springmvc实例记录(二)——shiro支持ajax请求
- 阿里云CentOS-7.2安装mysql