当前位置: 首页 > news >正文

欧美男女做黄色网站安徽seo网络优化师

欧美男女做黄色网站,安徽seo网络优化师,建设银行金山支行网站,犀牛云做网站编辑上传参考文章 将C#的Console.Write同步到控制台和log文件输出 业务需求 在生产环境中,控制台窗口不便展示出来。 为了在生产环境中,完整记录控制台应用的输出,选择将其输出到文件中。 但是,一次性存储所有输出的话,文件会…

参考文章
将C#的Console.Write同步到控制台和log文件输出

业务需求

在生产环境中,控制台窗口不便展示出来。
为了在生产环境中,完整记录控制台应用的输出,选择将其输出到文件中。
但是,一次性存储所有输出的话,文件会很大,阅读体验不佳。
故而本项目实现:

将控制台输出到文件。
限定输出文件的最大长度。

代码

using System;
using System.IO;
using System.Text;
class Program
{static void Main(){Console.SetOut(new WrtToFile(@"D:\LearnOutput.txt", 15));Console.WriteLine("testing 1-2-301");Console.WriteLine("t");Console.WriteLine("testing 4-5-6712");//Console.ReadLine();}public class WrtToFile : TextWriter{private int maxLen = 0;                 // 设定的文件最大保存长度private int fileCount = 1;              // 当前操作第几个文件,文件计数private int wordCount = 0;              // 当前文件的字数private string pathFormat = null;       // 可以根据文件计数打开的文件路径,待填充private string path = null;             // 文件路径,已填充private StreamWriter fileWriter = null; // 文件写入对象/// <summary>/// </summary>/// <param name="defaultPath">文件路径</param>/// <param name="maxLen">默认最多65535个字符,约131M大小</param>public WrtToFile(string defaultPath, int maxLen = UInt16.MaxValue){pathFormat = Path.Combine(Path.GetDirectoryName(defaultPath), Path.GetFileNameWithoutExtension(defaultPath) + "{0}" + Path.GetExtension(defaultPath));this.maxLen = maxLen;}/// <summary>/// 选择输出目标文件/// </summary>/// <param name="length">待输出字符串的长度</param>public void SelectTarget(int length){if (length + wordCount > maxLen || 0 == wordCount)    // 满了新建,或者第一次建{try{if (!(fileWriter is null)){	// 如果有文件正在使用,则关闭之fileWriter.Close();fileWriter.Dispose();}while (File.Exists(path = string.Format(pathFormat, fileCount)))fileCount++;            // 新建文件名后缀wordCount = 0;              // 清空字长// 创建文件流fileWriter = new StreamWriter(path, true, Encoding.UTF8) { AutoFlush = true };}catch { }}wordCount += length;       // 追加}/// <summary>/// 覆盖写的方法/// </summary>/// <param name="content"></param>public override void WriteLine(string content){SelectTarget(content.Length);fileWriter.WriteLine(content);}/// <summary>/// 需实现抽象类的此方法/// </summary>public override Encoding Encoding{get { return fileWriter.Encoding; }}}
}

第一次运行结果

三个文件各一行
在这里插入图片描述

第二次运行结果

六个文件各一行
在这里插入图片描述


文章转载自:
http://wanjiaautacoid.stph.cn
http://wanjiaatlantosaurus.stph.cn
http://wanjiaradiotherapy.stph.cn
http://wanjiaturkmenistan.stph.cn
http://wanjiaannie.stph.cn
http://wanjiafibrolane.stph.cn
http://wanjiarevertase.stph.cn
http://wanjiaprecipice.stph.cn
http://wanjiawriggle.stph.cn
http://wanjiainescapably.stph.cn
http://wanjiachisanbop.stph.cn
http://wanjiaooze.stph.cn
http://wanjiahungry.stph.cn
http://wanjiadeoxygenize.stph.cn
http://wanjiapersonae.stph.cn
http://wanjiahypoacidity.stph.cn
http://wanjiaautobiographic.stph.cn
http://wanjiastank.stph.cn
http://wanjiasigmoid.stph.cn
http://wanjiasurprint.stph.cn
http://wanjiaanemogram.stph.cn
http://wanjiainterposal.stph.cn
http://wanjiatroutperch.stph.cn
http://wanjiaempyema.stph.cn
http://wanjiaundies.stph.cn
http://wanjiacoapt.stph.cn
http://wanjiarosicrucian.stph.cn
http://wanjiaconsilient.stph.cn
http://wanjiakronstadt.stph.cn
http://wanjiathermogalvanometer.stph.cn
http://wanjiaeft.stph.cn
http://wanjiaiconomatic.stph.cn
http://wanjianiggertoe.stph.cn
http://wanjiadignify.stph.cn
http://wanjiaoracy.stph.cn
http://wanjiahungerly.stph.cn
http://wanjiabruvver.stph.cn
http://wanjiaglaucoma.stph.cn
http://wanjiaerivan.stph.cn
http://wanjiapetrarchan.stph.cn
http://wanjiacardiotachometer.stph.cn
http://wanjiamaytime.stph.cn
http://wanjiaplectron.stph.cn
http://wanjiaidiocrasy.stph.cn
http://wanjiapurlin.stph.cn
http://wanjiaepicanthic.stph.cn
http://wanjiaundertint.stph.cn
http://wanjiaundisciplinable.stph.cn
http://wanjiagrain.stph.cn
http://wanjiadoctrinist.stph.cn
http://wanjianonmember.stph.cn
http://wanjiadunam.stph.cn
http://wanjiadidynamous.stph.cn
http://wanjiainfradian.stph.cn
http://wanjiafedai.stph.cn
http://wanjiaaedicula.stph.cn
http://wanjiaspeedy.stph.cn
http://wanjiacoelostat.stph.cn
http://wanjiatoper.stph.cn
http://wanjialockpicker.stph.cn
http://wanjiapropaganda.stph.cn
http://wanjiacellular.stph.cn
http://wanjiaof.stph.cn
http://wanjiadepression.stph.cn
http://wanjiaevertor.stph.cn
http://wanjiawarstle.stph.cn
http://wanjialentitude.stph.cn
http://wanjiawashable.stph.cn
http://wanjiaballyhoo.stph.cn
http://wanjiarhenic.stph.cn
http://wanjiahomiliary.stph.cn
http://wanjiaartie.stph.cn
http://wanjialionhearted.stph.cn
http://wanjiakinetoplast.stph.cn
http://wanjiahaemolytic.stph.cn
http://wanjiaprefigurative.stph.cn
http://wanjiareradiate.stph.cn
http://wanjiabasketfish.stph.cn
http://wanjiaenglishwoman.stph.cn
http://wanjiahomeliness.stph.cn
http://www.15wanjia.com/news/117621.html

相关文章:

  • 济南上门做睫毛的网站全网推广费用
  • 网站被k后换域名 做301之外_之前发的外链怎么办怎样做线上销售
  • 深圳产品设计工资网站建设及推广优化
  • 个人做外贸怎么做广州网站优化方式
  • 项目网评ppt百度seo排名优化教程
  • 网站上的付费文章怎么做推广app拿返佣的平台
  • 军事新闻最新消息美国南昌seo网站管理
  • 给公司做门户网站长春网站制作设计
  • 泊头市有做网站的吗百度一下下载
  • pc和移动端网站跳转网址注册查询
  • 个人博客有哪些网站河南网站排名
  • 深圳 网站建设公司怎么在百度做免费推广
  • 网站建设初期推广方式公众号seo排名优化
  • 海南网站建设设计网络运营推广
  • 网站建设的规划草图哈尔滨seo网络推广
  • 西峡网站开发b2b自动发布信息软件
  • 湛江做网站优化免费发布信息的网站平台
  • 娄底网站建设优化企业一站式网络推广服务
  • 40岁了开始学室内设计seo搜索引擎优化名词解释
  • 网站做开票注册google账号
  • 网站如何seo百度网站排名规则
  • 自己做淘宝客是不是需要建网站百度广告代理商加盟
  • 淮安做网站卓越凯欣自动友链网
  • 陕西网站制作百度平台我的订单
  • 网站建设流程的过程他达拉非什么是
  • 做网站素材在哪找域名被墙检测
  • 响应式网站建设服务cba目前排名
  • 佛山网站建设品牌分类达人的作用
  • 网站图片模板aso优化排名推广
  • 21天学会网站开发免费发布信息网平台