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#读写文本和连接数据库的更多相关文章

  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. 读写文本(.txt)文件 .NET

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

  9. Unity 读写文本 文件

    1. LitJson的使用 https://blog.csdn.net/qq_35669619/article/details/78928966 https://blog.csdn.net/qq_14 ...

随机推荐

  1. IQueryable和list本地集合区别

    详情请看:http://www.cnblogs.com/imust/archive/2012/11/18/2776320.html

  2. html 文本超过显示省略号

    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;//显示行数 word-break: break-a ...

  3. 【转】XSD (xml Schema Definition)

    来自:http://www.cnblogs.com/newsouls/archive/2011/10/28/2227765.html Xml Schema的用途 1.  定义一个Xml文档中都有什么元 ...

  4. Windows10一周年庆典壁纸

    example: 下载:http://pan.baidu.com/s/1b55D5k

  5. isinstance

    class Foo: pass obj = Foo() isinstance(obj,Foo) class Foo: pass obj = Foo() isinstance(obj ,Foo) pri ...

  6. 大规模数据 从SQL SERVER导入到ORACLE方法

    来源于:http://blog.csdn.net/iitkd/article/details/40394789 来源:一个7G的SQL SERVER .bak文件要导入到Oracle中,经过实验,完成 ...

  7. SwipeRefreshLayout 首次打开出现加载图标

    最近要实现如何如图效果: 主要是在初始化,代码如下: , getResources().getDimensionPixelSize(typed_value.resourceId));    refre ...

  8. c语言中,既然不支持函数重载,那么printf算怎么回事?在c语言中,它不就是被重载了吗?

    这个问题问的不错.其实printf不是重载,c语言不支持函数重载 这句话是对的.printf函数是通过变长参数表实现的.你可以查看一下printf的函数原型声明.printf函数的实现在不同的机器上是 ...

  9. iOS开发小技巧--适当的清空模型中的某个数据,达到自己的需求,记得最后将数据还原(百思项目评论页面处理最热评论)

    一.项目需求,显示所有贴的时候,需要显示最热评论,但是点击进入相应帖子后,最热评论的label不要显示,如图: 解决方案 -- 该暂时保存的暂时保存,该清空的清空                   ...

  10. Shell命令_if

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 #if if [ 条件判断式 ] ...