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>");后台弹出提交成功

  • 相关阅读:
    盛最多水的容器
    除自身以外数组的乘积
    组合总和
    旋转图像
    找到所有数组中消失的数字
    RSA加密、签名机制
    SpringBoot-从新建一个项目看起
    linux下vi命令修改文件及保存的使用方法
    集合
    第一个注解式的SpringMVC项目
  • 原文地址:https://www.cnblogs.com/zcwry/p/2782535.html
Copyright © 2011-2022 走看看