zoukankan      html  css  js  c++  java
  • wince下写入数据到csv/txt文件中

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    using SmartDeviceProject1.WebReference;
    using System.Reflection;
    
    namespace SmartDeviceProject1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            
            StreamWriter sw = null;
            private void button1_Click(object sender, EventArgs e)
            {
                string path = @"My Documents入库.csv";//保存文件的路径
                try
                {
                    if (File.Exists(path))//如果文件已创建
                    {
                        this.sw = File.AppendText(path);
                        this.sw.WriteLine("叠加数据,123," + DateTime.Now.ToShortDateString());
                    }
                    else
                    {
                        this.sw = new StreamWriter(path);//如果没有创建
    this.sw.WriteLine("新建数据,789," + DateTime.Now.ToShortDateString()); } } catch (Exception ex)//异常处理 { MessageBox.Show(ex.Message); } finally { //清空缓冲区 this.sw.Flush(); //关闭流 this.sw.Close(); } } } }

    vs2008测试正常。

  • 相关阅读:
    java线程
    windows Server 安装
    nginx正则反向代理
    crontab定时任务启动脚本失败
    数据结构
    异常概念
    shell日期遍历复制文件
    多态和抽象
    图1 列出连通集
    PTA 代码注意事项
  • 原文地址:https://www.cnblogs.com/tiaoma888/p/4150434.html
Copyright © 2011-2022 走看看