zoukankan      html  css  js  c++  java
  • .net写本地文件的一个方法

    整理代码,.net在本地写html文件的一个方法,代码如下

     1 public static void WriteFile(string FilePath, string FileInfo, string Encode = "GB2312")
     2     {
     3         try
     4         {
     5             if (System.IO.File.Exists(FilePath)) System.IO.File.Delete(FilePath);
     6             System.IO.File.WriteAllText(FilePath, FileInfo, Encoding.GetEncoding(Encode));
     7         }
     8         catch (Exception)
     9         {
    10         }
    11     }

    调用方法如下:

    var strFileCn = File.ReadFile(MapPath("order_model.html"), "utf-8");//构建html文件内容
    strFileCn = strFileCn.Replace("#orderid#", orders.orderid);
    strFileCn = strFileCn.Replace("#username#", orders.username);
    var strRocFileName = "/ROC/" + orders.orderid + ".htm";//文件地址
    strRocFileName = Server.MapPath(strRocFileName);

    WriteFile(strRocFileName, strFileCn, "utf-8");

  • 相关阅读:
    模拟登录
    服务器的
    多线程爬虫
    新浪微博
    。。
    ** turtle模块和random模块
    收藏链接python--向大神学习
    126邮箱发送邮件测试1
    LabVIEW版本控制(转)
    正交编码器单端转差分
  • 原文地址:https://www.cnblogs.com/Lvkang/p/9352976.html
Copyright © 2011-2022 走看看