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. 【JQuery】jQuery.inArray 确定第一个参数在数组中的位置

    函数:jQuery.inArray(value,array,[fromIndex]) 解释:         value:用于在数组中查找是否存在         array:待处理数组.       ...

  2. 【心得】在脱离TFS的情况下,如何解除TFS绑定?

    我们知道在有TFS的情况下,在文件-源代码管理-高级中可以解除TFS绑定. 但是如果我们出差去了,拿着笔记本电脑,打开解决方案的时候,会总是提示无法连接TFS,并且在源代码管理处尝试解除的时候也提示无 ...

  3. php 解析json

    今天做项目的时候需要用到json数组,解析时遇到了个小小的麻烦,特此将解决办法记下: json数据如下: { "code":200, "message":&qu ...

  4. java虚拟机和Dalvik虚拟机的区别

    java虚拟机和Dalvik虚拟机的区别: java虚拟机Dalvik虚拟机 java虚拟机基于栈. 基于栈的机器必须使用指令来载入和操作栈上数据,所需指令更多更多dalvik虚拟机是基于寄存器的 j ...

  5. wsdl中含ref="s:schema"时处理的

    dos窗口,在生成客户端代码的时候,出现了下图所示的错误: java是通过JAXB解析wsdl文件的,出现这种错误的原因是: 是JAXB目前还不支持ref 这种元素的解析 s:schema是types ...

  6. iOS开发小技巧--根据文字,计算label中文字高度

  7. FastDFS搭建及java整合代码【转】

    FastDFS软件介绍 1.什么是FastDFS FastDFS是用C语言编写的一款开源的分布式文件系统.FastDFS为互联网量身定制,充分考虑了冗余备份.负载均衡.线性扩容等机制,并注重高可用.高 ...

  8. mysql基础语法及拓展到web中的sql注入

    本来是想写下javaweb的mvc(tomcat, spring, mysql)的搭建,  昨天搭到凌晨3点, 谁知道jdbcTemplate的jar包不好使, 想死的心都有了, 想想还是休息一下, ...

  9. eclipse中maven install和build,clean

    eclipse插件,m2eclipse 1.maven install相当于maven原生的命令: mvn install 2.aven build是 m2eclipse这个插件自己创造的概念,需要你 ...

  10. MWeb

    专业的 Markdown 写作支持 极简 UI.Dark Mode.漂亮的 Markdown 语法高亮.列表缩进优化,提供 5 种主题选择. 除了支持基本的 Markdown 语法外,还支持大量 Ma ...