C#读写文本和连接数据库
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.IO; namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
string conn = "Data Source=(local); Database=modelsearch3;Integrated Security=SSPI;";
SqlConnection objcon = new SqlConnection(conn);
SqlDataAdapter adapter;
adapter = new SqlDataAdapter("select * from model", objcon);
SqlCommandBuilder sqlBuilder = new SqlCommandBuilder(adapter);
objcon.Open();
DataTable dt = new DataTable("model");
adapter.Fill(dt);
for (int i = ; i < ; i++)
{
DataRow row = dt.Rows[i];
string f = row.ItemArray[].ToString();
string s = row.ItemArray[].ToString();
string t = row.ItemArray[].ToString();
//StreamWriter fw = File.AppendText("C:\\frontString.txt");
//fw.Write(f + "\r\n");
//StreamWriter sw = File.AppendText("C:\\sideString.txt");
//sw.Write(s + "\r\n");
//StreamWriter tw = File.AppendText("C:\\topString.txt");
//tw.Write(t + "\r\n");
StreamWriter zw = File.AppendText("C:\\modelString.txt");
zw.Write(f + s + t + "\r\n");
//fw.Close();
//sw.Close();
//tw.Close();
zw.Close();
}
}
}
}
参考:
http://zhidao.baidu.com/question/318486288.html
http://www.cnblogs.com/aidd2008/archive/2008/12/05/1348695.html
C#读取文本
int file_count = ;
StreamReader front_file_reader = new StreamReader("C:\\front_coordinate_add.txt");
StreamReader side_file_reader = new StreamReader("C:\\side_coordinate_add.txt");
StreamReader top_file_reader = new StreamReader("C:\\top_coordinate_add.txt"); ArrayList frontFeature = new ArrayList(); //前台sketch的特征符 (front)
ArrayList sideFeature = new ArrayList(); //前台sketch的特征符 (side)
ArrayList topFeature = new ArrayList(); //前台sketch的特征符 (top) while (file_count < )
{
string front_file_route = "";
front_file_route = front_file_reader.ReadLine(); string side_file_route = "";
side_file_route = side_file_reader.ReadLine(); string top_file_route = "";
top_file_route = top_file_reader.ReadLine(); string front_coordinate_str = "";
//char[] front_buffer = new char[30000];
StreamReader front_reader = new StreamReader(front_file_route);
//front_reader.Read(front_buffer,0,29999);
front_coordinate_str = front_reader.ReadLine();
//string front_coordinate_str = new string(front_buffer);
front_reader.Close(); string side_coordinate_str = "";
StreamReader side_reader = new StreamReader(side_file_route);
side_coordinate_str = side_reader.ReadLine();
side_reader.Close(); string top_coordinate_str = "";
StreamReader top_reader = new StreamReader(top_file_route);
top_coordinate_str = top_reader.ReadLine();
top_reader.Close(); bool result = WordStreamMatching.getInstance().matching(front_coordinate_str, side_coordinate_str, top_coordinate_str, ref frontFeature, ref sideFeature, ref topFeature); if (!result)
MessageBox.Show(""); file_count++;
}
C#读写文本和连接数据库的更多相关文章
- 背水一战 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为文件 ...
- 读写文本(.txt)文件 .NET
http://www.cnblogs.com/jx270/archive/2013/04/14/3020456.html (一) 读取文件 如果你要读取的文件内容不是很多,可以使用 File.Read ...
- Unity 读写文本 文件
1. LitJson的使用 https://blog.csdn.net/qq_35669619/article/details/78928966 https://blog.csdn.net/qq_14 ...
随机推荐
- input用法,永远等待,直到用户输入值赋值给一个东西。
input用法,永远等待,直到用户输入值赋值给一个东西. n1 = input('请输入用户名:') n1 = input('请输入密码:') print(n1) print(n1)
- [转]Hibernate查询对象所有字段,单个字段 ,几个字段取值的问题
原文地址:http://www.ablanxue.com/prone_3552_1.html 1. 查询整个映射对象所有字段 Java代码 //直接from查询出来的是一个映射对象,即:查询整个映射对 ...
- 简单解决ListView和ScrollView冲突,复杂情况仅供参考
ScrollView嵌套ListView冲突问题的最优解决方案 (转) 记录学习之用 项目做多了之后,会发现其实 ScrollView嵌套ListVew或者GridView等很常用,但是你也会发现各种 ...
- 【POJ 1743】Musical Theme
后缀数组求了height,模板题啦啦啦 #include<cstdio> #include<cstring> #include<algorithm> using n ...
- ie-css3.htc 可以让IE低版本浏览器支持CSS3 的一个小工具
ie-css3.htc 先说道说道这斯是弄啥嘞 ie-css3.htc是一个可以让IE浏览器支持部份CSS3属性的htc文件,不只是box-shadow,它还可以让你的IE浏览器支持圆角属性borde ...
- wamp 中如何管理两个dedeCms站点
本文以WampServer2.1为例,图文说明开启wamp虚拟主机功能,也就是绑定多域名,开启多站点搭建功能. 1. 我们一键安装wamp到E盘,并可以正常启动,状态如下图所示:
- c# 读取嵌入式文件
using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Reflect ...
- 76.Android之EventBus源码解析
转载:http://p.codekk.com/blogs/detail/54cfab086c4761e5001b2538 1. 功能介绍 1.1 EventBus EventBus 是一个 Andro ...
- macOS安装「oh my zsh」
目前常用的 Linux 系统和 OS X 系统的默认 Shell 都是 bash,但是真正强大的 Shell 是深藏不露的 zsh, 这货绝对是马车中的跑车,跑车中的飞行车,史称『终极 Shell』, ...
- 【poj1985】 Cow Marathon
http://poj.org/problem?id=1985 (题目链接) 题意 求树上两点间最长距离.题目背景以及输入描述请见poj1984. Solution 树的直径. 代码 // poj198 ...