using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{

try
{
var address = @"C:\Users\Administrator\Downloads\JSYD (12).mdb";
String str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + address + "'";
var con = new OleDbConnection(str);
con.Open();
OleDbCommand cmd = con.CreateCommand();

//获得数据

OleDbDataAdapter dagroup = new OleDbDataAdapter("select * from T_ZD_TYPE ", con);
DataSet dsgroup = new DataSet();
dagroup.Fill(dsgroup, "ddgroup");
var dt = dsgroup.Tables[0];
var str1 = "";
for (int i = 0; i < dt.Rows.Count; i++)
{
var type = dt.Rows[i]["TYPE"];
var mc = dt.Rows[i]["MC"];
var dm = dt.Rows[i]["DM"];
var typeBZ = dt.Rows[i]["TYPEBZ"];
str1 += string.Format("<dict name ='' key = '{0}' value = '{1}' type ='{2}' desc = '{3}' />\r\n", dm, mc, type, typeBZ);
}
WriteLogFile(str1);
con.Close();
con.Dispose();

}

catch (Exception ex)
{
//con.Close();
//con.Dispose();
throw ex;
}

}

/**/
/// <summary>
/// 写入日志文件
/// </summary>
/// <param name="input"></param>
public static void WriteLogFile(string input)
{
/**/
///指定日志文件的目录
string fname = Directory.GetCurrentDirectory() + "\\LogFile.txt";
/**/
///定义文件信息对象

FileInfo finfo = new FileInfo(fname);

if (!finfo.Exists)
{
FileStream fs;
fs = File.Create(fname);
fs.Close();
finfo = new FileInfo(fname);
}

/**/
///判断文件是否存在以及是否大于2K
if (finfo.Length > 1024 * 1024 * 10)
{
/**/
///文件超过10MB则重命名
File.Move(Directory.GetCurrentDirectory() + "\\LogFile.txt", Directory.GetCurrentDirectory() + DateTime.Now.TimeOfDay + "\\LogFile.txt");
/**/
///删除该文件
//finfo.Delete();
}
//finfo.AppendText();
/**/
///创建只写文件流

using (FileStream fs = finfo.OpenWrite())
{
/**/
///根据上面创建的文件流创建写数据流
StreamWriter w = new StreamWriter(fs);

/**/
///设置写数据流的起始位置为文件流的末尾
w.BaseStream.Seek(0, SeekOrigin.End);

/**/
///写入“Log Entry : ”
w.Write("\n\rLog Entry : ");

/**/
///写入当前系统时间并换行
w.Write("{0} {1} \n\r", DateTime.Now.ToLongTimeString(),
DateTime.Now.ToLongDateString());

/**/
///写入日志内容并换行
w.Write(input + "\n\r");

/**/
///写入------------------------------------“并换行
w.Write("------------------------------------\n\r");

/**/
///清空缓冲区内容,并把缓冲区内容写入基础流
w.Flush();

/**/
///关闭写数据流
w.Close();
}

}
}
}

最新文章

  1. IOS网络第七天WebView-01WebView和网页的交互1
  2. CMD命令小结
  3. 标题栏ToolBar
  4. Intellij快捷键
  5. 表视图控制器(TableViewController)(一)
  6. 火狐和IE之间的7个JavaScript差异
  7. 深度学习-使用cuda加速卷积神经网络-手写数字识别准确率99.7%
  8. [DevExpress]SplitContainerControl使用小计
  9. 浅谈web前端就业的学习路线
  10. js数组练习
  11. linux服务之NFS和SAMBA服务
  12. C# Excel数据导入到数据库
  13. Dynamics CRM 2015Online Update1 new feature之 插件跟踪日志
  14. WireShark捕获HTTPS
  15. dubbo实用知识点总结(二)
  16. Python全栈之路----函数
  17. 关于scanf、getchar、getch、getche缓冲区分析——C语言
  18. UVA 227 Puzzle(基础字符串处理)
  19. 深入理解JAVA虚拟机阅读笔记4——虚拟机类加载机制
  20. ubuntu C++开发环境

热门文章

  1. 集训Day13
  2. win8、win10下卸载程序报错误2502、2503的解决办法
  3. poj1475 Pushing Boxes[双重BFS(毒瘤搜索题)]
  4. 洛谷 P2858 [USACO06FEB]奶牛零食Treats for the Cows
  5. linux——boot空间不足
  6. nagios客户端安装与配置windows篇
  7. Ext.net Calendar 控件在有模板页的时候,模板页定义了TD的样式造成日历控件的样式丢掉
  8. ASP.NEt ajax 弹出窗口在页面无法关闭
  9. clone分支,修改文件本地commit后, push回原分支失败,处理方法
  10. python3登陆接口测试