首页 > Web开发 > 详细

.Net实现IO操作

时间:2014-03-20 18:16:48      阅读:432      评论:0      收藏:0      [点我收藏+]

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();

.Net实现IO操作,布布扣,bubuko.com

.Net实现IO操作

原文:http://www.cnblogs.com/wr1437/p/3614143.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!