当前位置: 首页>>代码示例>>C#>>正文


C# FileInfo.AppendText方法代码示例

本文整理汇总了C#中System.IO.FileInfo.AppendText方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.AppendText方法的具体用法?C# FileInfo.AppendText怎么用?C# FileInfo.AppendText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileInfo的用法示例。


在下文中一共展示了FileInfo.AppendText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: writeToFile

        static void writeToFile(string text)
        {
            FileInfo logFile;
            int day, month, year;
            day = DateTime.Now.Day;
            month = DateTime.Now.Month;
            year = DateTime.Now.Year;

            string fileName = "Logger_" + day + "_" + month + "_" + year;
            logFile = new FileInfo(HostingEnvironment.ApplicationPhysicalPath + @".\Logs\" + fileName);
            if (!logFile.Exists)
            {
                using(StreamWriter sw = logFile.CreateText())
                {
                    sw.WriteLine(DateTime.Now + " : " + text);
                }
            }
            else
            {
                using(StreamWriter sw = logFile.AppendText())
                {
                    sw.WriteLine(DateTime.Now + " : " + text);
                }
            }
        }
开发者ID:leaswis,项目名称:TempPossibleTrash,代码行数:25,代码来源:Logger.cs

示例2: SaveToFile

 public void SaveToFile(string fileName)
 {
     var file = new FileInfo(@fileName);
     var stream = file.AppendText();
     this.WriteFactors(stream);
     stream.Close();
 }
开发者ID:PeterLuschny,项目名称:Fast-Factorial-Functions,代码行数:7,代码来源:FactorialFactors.cs

示例3: PrintGErrs

        /*
         *            FOR DEBUG ONLY
         */
        internal void PrintGErrs(int indGlyph)
        {
            FileInfo infoFile=new FileInfo("GERRS.txt");
            StreamWriter writer=infoFile.AppendText();
            writer.WriteLine("===> GLYPH "+indGlyph);

            GErrList gerrlist=this.gerrlists[indGlyph] as GErrList;
            
            if (gerrlist!=null)
            {
                writer.WriteLine("NUMBER of ERRORS: "+gerrlist.Length);
            }
            else
            {
                writer.WriteLine("EMPTY LIST");
                writer.Close();
                return;
            }
            foreach (GErr gerr in gerrlist)
            {
                string str=gerr.Write();
                writer.WriteLine("");
                writer.WriteLine("Error: ");
                writer.Write(str);
            }
            writer.Close();

        }
开发者ID:bitforks,项目名称:Font-Validator,代码行数:31,代码来源:GErrPool.cs

示例4: LogError

 /// <summary>
 /// Log an error to the log file
 /// </summary>
 /// <param name="toLog">The error text to log</param>
 internal static void LogError(string toLog)
 {
     // Should this be logged?
     if(Log)
     {
         StreamWriter sw = null;
         try
         {
             // We want to open the file and append some text to it
             FileInfo file = new FileInfo(logFile);
             sw = file.AppendText();
             sw.WriteLine(DateTime.Now);
             sw.WriteLine(toLog);
             sw.WriteLine();
             sw.Flush();
         }
         finally
         {
             if(sw != null)
             {
                 sw.Close();
             }
         }
     }
 }
开发者ID:aldrinmg,项目名称:SadPanda-1,代码行数:29,代码来源:Logger.cs

示例5: FileTelemetryConsumer

 public FileTelemetryConsumer(FileInfo file)
 {
     _logFileName = file.FullName;
     var fileExists = File.Exists(_logFileName);
     _logOutput = fileExists ? file.AppendText() : file.CreateText();
     file.Refresh();
 }
开发者ID:PaulNorth,项目名称:orleans,代码行数:7,代码来源:FileTelemetryConsumer.cs

示例6: Log

        public static void Log(string content)
        {
            FileInfo logFile = new FileInfo(GetDataFile("log.txt"));

            using (StreamWriter logStream = logFile.AppendText())
                logStream.Write(DateTime.Now.ToLongTimeString() + content + "\r\n");
        }
开发者ID:brainpage,项目名称:desktop-windows,代码行数:7,代码来源:Utils.cs

示例7: escreverFicheiro

 /*
  * Método que cria o ficheiro, se ainda não
  * existir, se existir, vai acrescentar ao ficheiro
  * o que for enviado para o ficheiro através
  * da variavél que recebe, a menssagem.
  * */
 public void escreverFicheiro(string menssagem)
 {
     FileInfo file = new FileInfo("EstatisticaLP_C#.txt");
     StreamWriter Txt = file.AppendText();
     Txt.WriteLine(menssagem);
     Txt.Close();
 }
开发者ID:crijop,项目名称:estig-lp-1011-csharp-5608,代码行数:13,代码来源:EscreverFicheiro.cs

示例8: Log

 public void Log(String src, String message)
 {
     FileInfo file = new FileInfo(src);
     StreamWriter sw = file.AppendText();
     sw.WriteLine(message);
     sw.Close();
 }
开发者ID:alenkacz,项目名称:Expanze,代码行数:7,代码来源:Logger.cs

示例9: Main

        static void Main(string[] args)
        {
            var sourceFile = new System.IO.FileInfo(@"C:\Users\pasca\Desktop\voc-it.mdb");
            var stenoEntries = Converter.Parse(sourceFile);
            var filtered = stenoEntries.GroupBy(_s => _s.WinstenoStroke).Select(_g => _g.First());
            Console.WriteLine("Loaded {0} entries from {1}, {2} after duplicates removal.", stenoEntries.Count(), sourceFile.Name, filtered.Count());
            foreach (var duplicates in stenoEntries.GroupBy(_s => _s.WinstenoStroke).Where(_g => _g.Count() > 1))
            {
                Console.WriteLine("Duplicate : {0}", duplicates.Key);
                foreach(var dup in duplicates)
                {
                    Console.WriteLine("\t{0} - {1}", dup.Complete, dup.Partial);
                }
            }
            var ploverEntries = filtered.SelectMany(_se => PloverEntry.FromWinstenoEntry(_se)).Where(_pe=>_pe != null);
            var plovedFiltered = ploverEntries.GroupBy(_s => _s.Strokes.ToString()).Select(_g => _g.First());

            var outFile = new FileInfo(String.Format("{0}.json", Path.GetFileNameWithoutExtension(sourceFile.FullName)));
            outFile.Delete();
            using (var outstream = outFile.AppendText())
            {
                outstream.Write("{\n");
                foreach (var entry in plovedFiltered)
                {
                    outstream.Write("\"{0}\": \"{1}\", \n", entry.Strokes, entry.Value);
                }
                outstream.Write("\"\": \"\"\n");
                outstream.Write("}");
            }
            Console.WriteLine("Written {0} entries in {1}", plovedFiltered.Count(), outFile.FullName);
        }
开发者ID:Skaaal,项目名称:StenturaArduino,代码行数:31,代码来源:Program.cs

示例10: WriteLog

		public string WriteLog(string s)
		{
			try
			{
				FileInfo fi = new FileInfo("J:\\_net\\sys.log");
				StreamWriter sw;
				if (fi.Exists)
					sw = fi.AppendText();
				else
					sw = fi.CreateText();
				sw.WriteLine(s + "\r\n");
				sw.Close();
			}
			catch (IOException ex)
			{
				return "IO Error";
			}
			catch (UnauthorizedAccessException ex)
			{
				return "Unauthorized Access";
			}
			catch (SecurityException ex)
			{
				return "Security Error";
			}
			catch (NotSupportedException ex)
			{
				return "not supported";
			}
			return "Hello World";
		}
开发者ID:jithuin,项目名称:infogeezer,代码行数:31,代码来源:WebService1.asmx.cs

示例11: Write

 public void Write(string content)
 {
     try
     {
         if (!Directory.Exists(_filePath))
         {
             Directory.CreateDirectory(_filePath);
         }
         if (_fileName.IndexOf("/", StringComparison.Ordinal) != -1)
         {
             _fileName = _fileName.Replace("/", "-");
         }
         string strLogName = _filePath + "\\" + _fileName;
         var logFile = new FileInfo(strLogName);
         var textFile = logFile.AppendText();
         //如果日志文件大于50M
         if (logFile.Length < 50000000)
         {
             textFile.WriteLine(content);
         }
         textFile.Close();
     }
     catch (Exception ex)
     {
         //
     }
 }
开发者ID:yaozd,项目名称:MemcachedPerformance,代码行数:27,代码来源:MyLog.cs

示例12: OutputLogToFile

        private static void OutputLogToFile(int type, string tag, string message)
        {
#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX
            switch (type)
            {
                case LOG_TYPE_INFO:
                    tag = "I: " + tag;
                    break;
                case LOG_TYPE_WARNING:
                    tag = "W: " + tag;
                    break;
                case LOG_TYPE_ERROR:
                    tag = "E: " + tag;
                    break;
            }
            StreamWriter sw;
            FileInfo t = new FileInfo(Application.dataPath + "//Log.txt");
            if (!t.Exists)
            {
                sw = t.CreateText();
            }
            else
            {
                sw = t.AppendText();
            }
            sw.WriteLine(tag + message);
            sw.Close();
            sw.Dispose();
#endif
        }
开发者ID:xinfushe,项目名称:AndroidUtils-for-Unity3D,代码行数:30,代码来源:LogUtils.cs

示例13: PrintF

        public static void PrintF(String line)
        {
            String day = DateTime.Now.ToString("yyyyMMdd");
            FileInfo fileInfo = new FileInfo(Config.GetPath() + "log_"+ day + ".log");
            //   Console.WriteLine("PrintF");
            /*
            음 이것도.. UI 쓰레드에서 돌리면 부하가 걸리는구나..
            그럼 결국엔.. 이것도.. 큐에 넣었다가
            쓰레드로 파일에 쓰는 작업을 해야겠네..

            */
            lock (locker)
            {
                /*
                String tmp1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                line = "[" + tmp1 + "]" + line;
                System.IO.StreamWriter file = new System.IO.StreamWriter(path, true);
                file.WriteLine(line);
                file.Close();
                */
                String tmp1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                line = "[" + tmp1 + "]" + line;
                using (StreamWriter FileWriter = fileInfo.AppendText())
                {
                    FileWriter.WriteLine(line);
                }
            }

            /* 오히려 쓰레드가 더 느리네.. 쓰레드 삭제.
            Thread t1 = new Thread(() => WirteFile(line));
            t1.Start();
            */
        }
开发者ID:jijoungsoo,项目名称:kiumopenapi,代码行数:33,代码来源:FileLog.cs

示例14: LogSingleEvent

        public static void LogSingleEvent(string logIndicationText)
        {
            StreamWriter strm;
            string logFileName;
            string workdir = ConfigurationManager.AppSettings["DirectorioTrabajo"];

            logFileName = String.Concat(workdir,
                ConfigurationManager.AppSettings["LogFileNameFormat"]);

            FileInfo archivo = new FileInfo(logFileName);
            DateTime yesterday = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0));

            if (archivo.Exists)
            {
                if (String.Compare(archivo.LastWriteTime.ToString("yyyyMMdd"), yesterday.ToString("yyyyMMdd")) < 0)
                {
                    archivo.Delete();
                    strm = archivo.CreateText();
                }
                else
                {
                    strm = archivo.AppendText();
                }
            }
            else
                strm = archivo.CreateText();

            strm.WriteLine(String.Format("{0} - {1}",
                DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff"), logIndicationText));

            strm.Close();
        }
开发者ID:quiquesys,项目名称:PFACW0001,代码行数:32,代码来源:BitWriter.cs

示例15: BitWriter

        /// <summary>
        /// Inicializa el archivo tambien para su escritura
        /// </summary>
        public BitWriter(string workdir)
        {
            string logFileName;

            logFileName = String.Concat(workdir,
                ConfigurationManager.AppSettings["LogFileNameFormat"]);

            FileInfo archivo = new FileInfo(logFileName);
            DateTime yesterday = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0));

            if (archivo.Exists)
            {
                if (String.Compare(archivo.LastWriteTime.ToString("yyyyMMdd"), yesterday.ToString("yyyyMMdd")) < 0)
                {
                    archivo.Delete();
                    logStream = archivo.CreateText();
                }
                else
                {
                    logStream = archivo.AppendText();
                }
            }
            else
                logStream = archivo.CreateText();

            logStream.WriteLine(String.Format("--- Inicio de control {0} ---",
                DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")));
        }
开发者ID:quiquesys,项目名称:PFACW0001,代码行数:31,代码来源:BitWriter.cs


注:本文中的System.IO.FileInfo.AppendText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。