dataGridView读写文本
constant con = new constant();
private void loadlistbox2()
{
dataGridView1.ColumnCount = 1;
string z;
if (File.Exists(".//allitems.txt"))
{
FileStream fs = new FileStream(".//allitems.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read);
StreamReader sr = new StreamReader(fs, System.Text.Encoding.GetEncoding("utf-8"));
try
{
while (true)
{
z = sr.ReadLine();
if (z == null) break;
dataGridView1.Rows.Add(z);
}
}
finally
{
sr.Close();
fs.Dispose();
fs.Close();
}
}
}
string st = "";
private void savetestitem()
{
// dataGridView1.ColumnCount = 1;
if (File.Exists(".//allitems.txt"))
{
FileStream fs = new FileStream(".//allitems.txt", System.IO.FileMode.Open, System.IO.FileAccess.Write);
StreamWriter sr = new StreamWriter(fs, System.Text.Encoding.GetEncoding("utf-8"));
try
{
for (int i = 0; i < 22; i++)
{
for (int j = 0; j < 1; j++)
{
st = st + dataGridView1.Rows[i].Cells[j].Value;
}
sr.WriteLine(st);
st = "";
//for (int i = 0; i < dataGridView1.Rows.Count; i++)
//{
// sr.WriteLine(dataGridView1.Rows[i].Cells);
// }
}
}
finally
{
sr.Close();
fs.Dispose();
fs.Close();
}
}
}
dataGridView读写文本的更多相关文章
- 背水一战 Windows 10 (89) - 文件系统: 读写文本数据, 读写二进制数据, 读写流数据
[源码下载] 背水一战 Windows 10 (89) - 文件系统: 读写文本数据, 读写二进制数据, 读写流数据 作者:webabcd 介绍背水一战 Windows 10 之 文件系统 读写文本数 ...
- iOS 9应用开发教程之多行读写文本ios9文本视图
iOS 9应用开发教程之多行读写文本ios9文本视图 多行读写文本——ios9文本视图 文本视图也是输入控件,与文本框不同的是,文本视图可以让用户输入多行,如图2.23所示.在此图中字符串“说点什么吧 ...
- python_py2和py3读写文本区别
python2和python3的区别? python 2 str 对应 python3 bytes python 2 uincode 对应 ...
- 零基础学python-3.7 还有一个程序 python读写文本
今天我们引入另外一个程序,文件的读写 我们先把简单的程序代码贴上.然后通过我们多次的改进.希望最后可以变成一个简单的文本编辑器 以下是我们最简单的代码: 'crudfile--读写文件' def re ...
- Python之读写文本数据
知识点不多 一:普通操作 # rt 模式的 open() 函数读取文本文件 # wt 模式的 open() 函数清除覆盖掉原文件,write新文件 # at 模式的 open() 函数添加write ...
- Python-py2和py3读写文本区别
python2和python3的区别? python 2 str 对应 python3 bytes python 2 uincode 对应 ...
- delphi 读写文本
将字符串写入txt文档,读取txt文档中的内容. //一次写字符串到文本文件,每次都会将原来的内容替换掉. procedure FilePutContents(f,s:String); // f为文件 ...
- C#读写文本和连接数据库
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 读写文本(.txt)文件 .NET
http://www.cnblogs.com/jx270/archive/2013/04/14/3020456.html (一) 读取文件 如果你要读取的文件内容不是很多,可以使用 File.Read ...
随机推荐
- “未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序
一.背景: 开发一个工具的小项目,因为数据少,我就不想安装sqlserver数据库,就用Access数据库. 二.问题: 在客户安装程序的时候,接口访问Access数据库的时候,报错“未在本地计算机上 ...
- leetcode 85. 最大矩形
题目描述: 给定一个仅包含 0 和 1 的二维二进制矩阵,找出只包含 1 的最大矩形,并返回其面积. 思路分析: 这题是之前那道最大正方形的进阶,同样是利用dp来求解.通过逐行去计算最大矩形,即优化的 ...
- /etc/resolv.conf options rotate
timeout:n sets the amount of time the resolver will wait for a response from a remote name server ...
- ubuntu下Vim安装失败
sudo apt-get install vim Reading package lists... Done Building dependency tree Reading state inform ...
- 【Eclipse】Eclipse如何导出java项目为jar包
1.首先确定要导出的项目 从项目结构可以看出,笔者的项目是一个Dynamic Java Project.com/db下面有一个config的数据库配置文件.WEB-INF/lib文件夹下面有依赖的ja ...
- 虚拟机 /dev/mapper/centos-root 动态扩容
[root@bogon ~]# df -h Filesystem Size Used Avail Use% Mounted on .2G .2G 51M % / devtmpfs 908M 908M ...
- Java类成员初始化顺序
类中包含7中成员:1.静态变量 static2.final静态常量 final static3.静态代码块 static{} //多个代码块顺序执行 4.普通变量5.普通代码块 {} //多个代码 ...
- MySQL导数据笔记
2019-12-16 9:08:43 星期一 MySQL 5.6 limit / order 有bug, 如果主键不是自增的, 只能全表导出导入, 增量导入导出的话会报主键重复 触发器: 批量导入数据 ...
- Java12新特性 -- 其他新增,移除,废弃项
支持unicode 11 JDK 12版本包括对Unicode 11.0.0的支持.在发布支持Unicode 10.0.0的JDK 11之后,Unicode 11.0.0引 入了以下JDK 12中包含 ...
- 在nginx环境下搭建https服务,代理到本地web项目
安装过程略. 1.证书准备 本地调试,可以安装自签名证书,安装方法参考https本地自签名证书添加到信任证书访问 2.修改配置文件 将上面的配置文件拷贝到conf目录,添加或者修改节点如下 http{ ...