zoukankan      html  css  js  c++  java
  • Asp.NET写文件的一个小实例程序

    #region 写文件
            /****************************************
             * 函数名称:WriteFile
             * 功能说明:当文件不存时,则创建文件,并追加文件
             * 参    数:Path:文件路径,Strings:文本内容
             * 调用示列:
             *           string Path = Server.MapPath("Default2.aspx");      
             *           string Strings = "这是我写的内容啊";
             *           EC.FileObj.WriteFile(Path,Strings);
            *****************************************/
            /// <summary>
            /// 写文件
            /// </summary>
            /// <param name="Path">文件路径</param>
            /// <param name="Strings">文件内容</param>
            public static void WriteFile(string Path, string Strings)
            {
                if (!System.IO.File.Exists(Path))
                {
                    System.IO.FileStream f = System.IO.File.Create(Path);
                    f.Close();
                }
                System.IO.StreamWriter f2 = new System.IO.StreamWriter(Path, true, System.Text.Encoding.GetEncoding("gb2312"));
                f2.WriteLine(Strings);
                f2.Close();
                f2.Dispose();
            }
            #endregion
  • 相关阅读:
    hdu1828线段树(两次扫描+离散化)
    hdu1542线段树(扫描线+离散化)
    二分思想
    hdu2871线段树区间更新
    git初体验
    python笔记-模块
    python笔记-动态类型
    AWS上创建EKS(K8S)集群
    Akamai CDN刷新(通过Akamai cli 自动刷新)
    创建Akamai cdn api授权
  • 原文地址:https://www.cnblogs.com/yangxiaohu1/p/1496420.html
Copyright © 2011-2022 走看看