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读写文本的更多相关文章

  1. 背水一战 Windows 10 (89) - 文件系统: 读写文本数据, 读写二进制数据, 读写流数据

    [源码下载] 背水一战 Windows 10 (89) - 文件系统: 读写文本数据, 读写二进制数据, 读写流数据 作者:webabcd 介绍背水一战 Windows 10 之 文件系统 读写文本数 ...

  2. iOS 9应用开发教程之多行读写文本ios9文本视图

    iOS 9应用开发教程之多行读写文本ios9文本视图 多行读写文本——ios9文本视图 文本视图也是输入控件,与文本框不同的是,文本视图可以让用户输入多行,如图2.23所示.在此图中字符串“说点什么吧 ...

  3. python_py2和py3读写文本区别

    python2和python3的区别? python 2  str             对应      python3 bytes python 2 uincode            对应   ...

  4. 零基础学python-3.7 还有一个程序 python读写文本

    今天我们引入另外一个程序,文件的读写 我们先把简单的程序代码贴上.然后通过我们多次的改进.希望最后可以变成一个简单的文本编辑器 以下是我们最简单的代码: 'crudfile--读写文件' def re ...

  5. Python之读写文本数据

    知识点不多 一:普通操作  # rt 模式的 open() 函数读取文本文件 # wt 模式的 open() 函数清除覆盖掉原文件,write新文件 # at 模式的 open() 函数添加write ...

  6. Python-py2和py3读写文本区别

    python2和python3的区别? python 2  str             对应      python3 bytes python 2 uincode            对应   ...

  7. delphi 读写文本

    将字符串写入txt文档,读取txt文档中的内容. //一次写字符串到文本文件,每次都会将原来的内容替换掉. procedure FilePutContents(f,s:String); // f为文件 ...

  8. C#读写文本和连接数据库

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  9. 读写文本(.txt)文件 .NET

    http://www.cnblogs.com/jx270/archive/2013/04/14/3020456.html (一) 读取文件 如果你要读取的文件内容不是很多,可以使用 File.Read ...

随机推荐

  1. Centos7 更改yum源与更新系统

    [1] 首先备份 /etc/yum.repos.d/CentOS-Base.repo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/Cen ...

  2. JQuery的Ajax标准写法

    Ajax的标准写法 $.ajax({ url:"http://www.xxx",//请求的url地址 dataType:"json",//返回的格式为json ...

  3. iptables 限制端口

    限制端口 #!/bin/bashiptables -P INPUT ACCEPTiptables -P OUTPUT ACCEPTiptables -Fiptables -P INPUT DROPip ...

  4. RFC-6455 The WebSocket Protocol 浅读

    什么是WebSokcet? WebSocket是一种协议,并且是各大主流浏览器作为客户端支持的协议.它的目标就是用来替代基于 XMLHTTPRequest和长轮询的解决方案.应用在时时弹幕,消息推送, ...

  5. jetty源码下载

    jetty下载地址:https://www.eclipse.org/jetty/download.html Release         9.4.20.v20190813 .zip .tgz api ...

  6. C++ list运用实例

    C++ list运用实例 #include <list> #include <iostream> #include <algorithm> #include < ...

  7. pycharm安装、首次使用及汉化

    摘自:https://blog.csdn.net/qq_30463497/article/details/84992480 一.下载pycharm安装包打开PyCharm的官方下载地址:http:// ...

  8. Egret自定义位图文字(自定义+BitmapLabel)

    一 自定位图文字 因为egret的位图文字是texturemerger做的,需要多张单图片导入tm,然后导出两个文件来使用,过程比较麻烦. 而Laya的位图文字则是一张整图数字图片,使用FontCli ...

  9. Laya的List组件+滚动条

    版本:2.2.0 下面以<绯雨骑士团>的服务器选择列表为例子. 一 创建List 首先创建一个List组件,我命名为serverList. (不用像laya教程里那样,还要转换类型什么的, ...

  10. org.apache.hadoop.fs.FsUrlStreamHandlerFactory 在哪个jar包

    org.apache.hadoop.fs.FsUrlStreamHandlerFactory在org.apache.hadoop类中,org.apache.hadoop在hadoop安装目录下.