zoukankan      html  css  js  c++  java
  • .Net实现IO操作

    IO操作需要的web.config里的节点配置

    <configuration>
      <appSettings>
        <!--上传文件类型要求-->
        <add key="imgType" value=".jpg|.png|.gif"/>
        <!--存储上传图片的路径(虚拟路径)-->
        <add key="upImg" value="~/upImg"/>
      </appSettings>

      //获取指定目录下的子目录
               string[] _aryString=Directory.GetDirectories(@"D:");
               if (_aryString.Length == 0)
                   Response.Write("该目录下没有文件夹");
               else
               {
                   foreach (string _s in _aryString)
                       lbInfo.Items.Add(_s);
               }

        //设定当前时间为文件名
                string _strName = DateTime.Now.ToString("yyyyMMddhhmmssfff");
                //文件路径
                string _strPath = @"d:" + _strName + ".txt";
                //借助FileStream创建文件
                FileStream _fsFiles = new FileStream(_strPath, FileMode.Create);     

           //借助StreamWriter将信息写入流//第二个参数为编码设置,预防乱码
                StreamWriter _swInfo = new StreamWriter(_fsFiles, System.Text.Encoding.Default);
                //将要创建的文本信息写入流中
                _swInfo.Write(txtInfo.Text.Trim());
                //清楚缓冲区(实质是将信息写入文本文件)
                _swInfo.Flush();
                _swInfo.Close();
                _fsFiles.Close();

  • 相关阅读:
    python文本处理
    转 Deep Learning for NLP 文章列举
    backpropagation
    开发者必备的6款源码搜索引擎 转
    转【面向代码】学习 Deep Learning(二)Deep Belief Nets(DBNs)
    Sampling
    各种形式的熵函数,KL距离
    [转] 如何在ie11里使用a连接创建动态下载文件流
    修改chrome背景色
    [转] 使用 Spring 5 的 WebFlux 开发反应式 Web 应用
  • 原文地址:https://www.cnblogs.com/wr1437/p/3614143.html
Copyright © 2011-2022 走看看