c#文件流读写
来源:互联网 发布:ui设计师的前景 知乎 编辑:程序博客网 时间:2024/05/17 08:12
读写的完整流程例子可参考:stream简单读写excel
写文件:
string demo="写入txt中"; StreamWriter demo_log = null; demo_log = File.CreateText("demo_log.txt"); demo_log.WriteLine(demo,Encoding.GetEncoding("gb2312")); demo_log.Close();
demo_log.Dispose();
if (openFileDialog.ShowDialog() == DialogResult.OK) { string str = null; FileStream fs = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); StreamReader reader = new StreamReader(fs, System.Text.Encoding.Default); while ((str = reader.ReadLine()) != null) { // split the string //MessageBox.Show(str); string[] strs = str.Split('|'); } reader.Close(); }
读取图片的锁问题可以用克隆的方式解决:
// 通过生成clone的方式,使用clone来赋值,从而 FileSourcePath对应的图片得到解锁//System.Drawing.Image img = System.Drawing.Image.FromFile(FileSourcePath); System.Drawing.Image bmp = new System.Drawing.Bitmap(img); img.Dispose(); pictureBox1.Image = bmp; // System.Drawing.Image.FromFile(FileSourcePath); pictureBox1.Visible = true;
- c#文件流读写
- C#文件的读写 -流
- C# 文件流读写记事本
- C# FileStream流文件读写
- c# 文件流读写信息
- C#读写文件流方法
- C#的文件读写操作--流方式一次读写文件
- C#常用IO流与读写文件
- C#读写INI文件
- C#读写INI文件
- C#读写INI文件
- C#读写INI文件
- c#读写xml文件
- c#读写xml文件
- c#读写xml文件
- C#读写文件
- C# 文件读写
- C#读写xml文件
- UpdateData(TRUE)和UpdateData(FALSE)的区别
- 交叉验证
- 把Tomcat安装成windows服务
- 黑马程序员---构造函数与Static静态
- 多触点
- c#文件流读写
- mysql c/c++ 在Windows x64 下的问题.
- jstat使用方法
- Android Intent Action大全
- 软件级负载均衡器(LVS/HAProxy/Nginx)的特点简介和对比
- AsyncTask几点要注意的地方
- 结构体在网络中的传输
- 利用JMF进行多媒体编程[转]
- 测试成功安装hadoop