zoukankan      html  css  js  c++  java
  • 文件流的写入,把文件写入到当前项目中的一个文件夹里,以当前系统时间的年月命名

                string datenow = DateTime.Now.ToString();//获取当前的系统时间
                string psth =Server.MapPath( "/wenjian/" + DateTime.Now.ToString("yyyyMM") + ".csv");//将要写入的路径,当前的项目文件夹下
                //string path=Server.MapPath("wenjian")+"\\"+DateTime.Now.ToString("yyyyMM")+".txt";
                string xinphone = this.TextBox1.Text.ToString();
                string name = this.TextBox2.Text.ToString();
                string yinphone = this.TextBox3.Text.ToString();
                string yinfakayinghang = this.TextBox4.Text.ToString();
                string yindaokahao = this.TextBox5.Text.ToString();
                string now = DateTime.Now.ToString("yyyyMM");//获取当前的系统时间的年月
                FileStream fs = new FileStream(psth, FileMode.Append);//这是往哪个文件夹中写,APPend的意思就是看当前有无这个文件,如果有的话就打开往里追加,如果没有就新建一 个 这个文件
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine(xinphone + "," + name + "," + yinphone + "," + yinfakayinghang + "," + yindaokahao + "," + datenow);
        
                sw.Close();
                fs.Close();
                ClientScript.RegisterStartupScript(this.GetType(), "a", "<script>alert('提交成功')</script>");后台弹出提交成功

  • 相关阅读:
    Gradle gitignore Gradle 模式 上传SVN 要忽略的文件
    加速Android Studio/Gradle构建
    JAVA unicode转换成中文
    进程与线程
    Flask快速入门
    tensorflow入门指南
    BP神经网络与Python实现
    文档数据库MongoDB
    Python虚拟环境virtualenv
    Python爬虫框架Scrapy
  • 原文地址:https://www.cnblogs.com/zcwry/p/2782535.html
Copyright © 2011-2022 走看看