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


C# StreamWriter.WriteLine方法代码示例

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


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

示例1: Main

 static void Main(string[] args)
 {
     using (StreamWriter str = new StreamWriter(args[0]))
     {
         int a = Convert.ToInt32(args[1]);
         int b = Convert.ToInt32(args[2]);
         str.WriteLine("Parameters:");
         str.WriteLine(a);
         str.WriteLine(b);
         int min;
         if (a > b)
             min = b;
         else
             min = a;
         int i = min;
         int c = 0;
         while (i>0&&c==0)
         {
             if ((a % i == 0) && (b % i == 0))
                 c = i;
             i--;
         }
         //c = 0;
         str.WriteLine("Answers:");
         str.WriteLine(Convert.ToString(c));
         //str.WriteLine(a);
     }
 }
开发者ID:LearningSystem,项目名称:InformationSystem,代码行数:28,代码来源:Program.cs

示例2: AllFieldsEmptyTest

        public void AllFieldsEmptyTest()
        {
            using( var stream = new MemoryStream() )
            using( var reader = new StreamReader( stream ) )
            using( var writer = new StreamWriter( stream ) )
            using( var parser = new CsvParser( reader ) )
            {
                writer.WriteLine( ";;;;" );
                writer.WriteLine( ";;;;" );
                writer.Flush();
                stream.Position = 0;

                parser.Configuration.Delimiter = ";;";
                parser.Configuration.HasHeaderRecord = false;

                var row = parser.Read();
                Assert.IsNotNull( row );
                Assert.AreEqual( 3, row.Length );
                Assert.AreEqual( "", row[0] );
                Assert.AreEqual( "", row[1] );
                Assert.AreEqual( "", row[2] );

                row = parser.Read();
                Assert.IsNotNull( row );
                Assert.AreEqual( 3, row.Length );
                Assert.AreEqual( "", row[0] );
                Assert.AreEqual( "", row[1] );
                Assert.AreEqual( "", row[2] );

                row = parser.Read();
                Assert.IsNull( row );
            }
        }
开发者ID:KPK-Teamwork-Team-Bajic,项目名称:KPK-Teamwork,代码行数:33,代码来源:CsvParserDelimiterTests.cs

示例3: ExportToExcel

        private void ExportToExcel()
        {
            DgStats.SelectAllCells();
            DgStats.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader;
            ApplicationCommands.Copy.Execute(null, DgStats);
            var stats = (string) Clipboard.GetData(DataFormats.CommaSeparatedValue);
            //String result = (string)Clipboard.GetData(DataFormats..Text);
            DgStats.UnselectAllCells();

            DgUnmatched.SelectAllCells();
            DgUnmatched.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader;
            ApplicationCommands.Copy.Execute(null, DgUnmatched);
            var unmatched = (string) Clipboard.GetData(DataFormats.CommaSeparatedValue);
            DgUnmatched.UnselectAllCells();
            var saveFileDialog = new SaveFileDialog();
            saveFileDialog.FileName = string.Format("{0}.Reconcile.csv", Path.GetFileName(_vm.BankFile.FilePath));
            if (saveFileDialog.ShowDialog() == true)
            {
                var file = new StreamWriter(saveFileDialog.FileName);
                file.WriteLine(stats);
                file.WriteLine("");
                file.WriteLine(unmatched);
                file.Close();
            }
        }
开发者ID:FrankMedvedik,项目名称:coopcheck,代码行数:25,代码来源:AccountPaymentsView.xaml.cs

示例4: Trace

        public void Trace(NetState state)
        {
            try
            {
                string path = Path.Combine(Paths.LogsDirectory, "packets.log");                

                using (StreamWriter sw = new StreamWriter(path, true))
                {
                    sw.BaseStream.Seek(sw.BaseStream.Length, SeekOrigin.Begin);

                    byte[] buffer = _data;

                    if (_data.Length > 0)
                        Tracer.Warn(string.Format("Unhandled packet 0x{0:X2}", _data[0]));

                    buffer.ToFormattedString(buffer.Length, sw);

                    sw.WriteLine();
                    sw.WriteLine();
                }
            }
            catch (Exception e)
            {
                Tracer.Error(e);
            }
        }
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:26,代码来源:PacketReader.cs

示例5: SaveTo

 public static void SaveTo(string filename, MailAccess mailAccess) {
     using (var streamWriter = new StreamWriter(filename, false, Encoding.UTF8)) {
         streamWriter.WriteLine(mailAccess.Server);
         streamWriter.WriteLine(mailAccess.Username);
         streamWriter.WriteLine(mailAccess.Password);
     }
 }
开发者ID:slieser,项目名称:sandbox,代码行数:7,代码来源:MailAccessRepository.cs

示例6: ConvertFormat

        public static void ConvertFormat(string strInputFile, string strOutputFile)
        {
            StreamReader sr = new StreamReader(strInputFile);
            StreamWriter sw = new StreamWriter(strOutputFile);
            string strLine = null;

            while ((strLine = sr.ReadLine()) != null)
            {
                strLine = strLine.Trim();

                string[] items = strLine.Split();
                foreach (string item in items)
                {
                    int pos = item.LastIndexOf('[');
                    string strTerm = item.Substring(0, pos);
                    string strTag = item.Substring(pos + 1, item.Length - pos - 2);

                    sw.WriteLine("{0}\t{1}", strTerm, strTag);
                }
                sw.WriteLine();
            }

            sr.Close();
            sw.Close();
        }
开发者ID:zxz,项目名称:RNNSharp,代码行数:25,代码来源:Program.cs

示例7: WriteToLog

 /// <summary>
 /// Запись в ЛОГ-файл
 /// </summary>
 /// <param name="str"></param>
 public void WriteToLog(string str, bool doWrite = true)
 {
     if (doWrite)
     {
         StreamWriter sw = null;
         FileStream fs = null;
         try
         {
             string curDir = AppDomain.CurrentDomain.BaseDirectory;
             fs = new FileStream(curDir + "teplouchetlog.pi", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
             sw = new StreamWriter(fs, Encoding.Default);
             if (m_vport == null) sw.WriteLine(DateTime.Now.ToString() + ": Unknown port: adress: " + m_address + ": " + str);
             else sw.WriteLine(DateTime.Now.ToString() + ": " + m_vport.GetName() + ": adress: " + m_address + ": " + str);
             sw.Close();
             fs.Close();
         }
         catch
         {
         }
         finally
         {
             if (sw != null)
             {
                 sw.Close();
                 sw = null;
             }
             if (fs != null)
             {
                 fs.Close();
                 fs = null;
             }
         }
     }
 }
开发者ID:Prizmer,项目名称:tu_teplouchet,代码行数:38,代码来源:CMeter.cs

示例8: SaveLastCode

        private void SaveLastCode()
        {
            string filename = Path.Combine(localPath, "TestApp.os");
            using (var writer = new StreamWriter(filename, false, Encoding.UTF8))
            {
                // первой строкой запишем имя открытого файла
                writer.Write("//");  // знаки комментария, чтобы сохранить код правильным
                writer.WriteLine(_currentDocPath);
                // второй строкой - признак изменённости
                writer.Write("//");
                writer.WriteLine(_isModified);

                args.Text = args.Text.TrimEnd('\r', '\n');

                // запишем аргументы командной строки
                writer.Write("//");
                writer.WriteLine(args.LineCount);

                for (var i = 0; i < args.LineCount; ++i )
                {
                    string s = args.GetLineText(i).TrimEnd('\r', '\n');
                    writer.Write("//");
                    writer.WriteLine(s);
                }

                // и потом сам код
                writer.Write(txtCode.Text);
            }
        }
开发者ID:Shemetov,项目名称:OneScript,代码行数:29,代码来源:MainWindow.xaml.cs

示例9: exportCSV

        public void exportCSV(string filename)
        {
            StreamWriter tw = new StreamWriter(filename);

            tw.WriteLine("Filename;Key;Text");
            string fn;
            int i, j;
            List<string> val;
            string str;

            for (i = 0; i < LTX_Texte.Count; i++)
            {
                fn = LTX_Texte[i].Key.ToLower().Replace(".ltx","");
                val = LTX_Texte[i].Value;
                for (j = 0; j < val.Count; j++)
                {
                    str = prepareText(val[j], true);
                    if( str != "" )
                        tw.WriteLine(fn + ";" + j.ToString() + ";" + str);
                }
            }
            for (i = 0; i < DTX_Texte.Count; i++)
            {
                fn = DTX_Texte[i].Key.ToLower().Replace(".dtx","");
                val = DTX_Texte[i].Value;
                for (j = 0; j < val.Count; j++)
                {
                    str = prepareText(val[j], true);
                    if (str != "")
                        tw.WriteLine(fn + ";" + j.ToString() + ";" + str);
                }
            }

            tw.Close();
        }
开发者ID:tommy87,项目名称:DSA1-Editing-Tool,代码行数:35,代码来源:Texte.cs

示例10: Main

        static void Main(string[] args)
        {
            var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
              var items = Directory.GetFiles(dir, "*.jpg").ToList();
              items.AddRange(Directory.GetFiles(dir, "*.jpeg"));
              items.AddRange(Directory.GetFiles(dir, "*.gif"));
              items.AddRange(Directory.GetFiles(dir, "*.png"));

              //rename all the filesthat are samples
              const string SAM = "sample-";
              foreach (var item in items.Select(x => Path.GetFileName(x)).Where(x => x.StartsWith(SAM, StringComparison.CurrentCultureIgnoreCase)))
              {
            var newName = Path.Combine(dir, item.Substring(SAM.Length, item.Length-SAM.Length));
            var oldName = Path.Combine(dir, item);
            if (!items.Contains(newName))
              File.Copy(oldName, newName);
            File.Delete(oldName);
              }

              using (var sw = new StreamWriter(Path.Combine(dir, "dir.js"), false))
              {
            sw.WriteLine("var IMAGES = [");
            foreach (var item in items)
              sw.WriteLine("  \"{0}\",", Path.GetFileName(item)); //seems we don't have to worry about the extra comma
            sw.WriteLine("];");
              }
        }
开发者ID:jschlitz,项目名称:Slideshow,代码行数:27,代码来源:Program.cs

示例11: Guardar

        public void Guardar(Senial senial)
        {
            string _linea_dato = "";
            string _fecha = senial.fecha_adquisicion.ToString ("yyyy MMMMM dd");
            string _cantidad = senial.CantidadValores().ToString();
            string _id = senial.Id.ToString ();
            string _nombre = _ubicacion + "/" + _id + " - " + _fecha + ".txt";

            try
            {
                using (StreamWriter _archivo = new StreamWriter(_nombre))
                {
                    string cabecera = _id + ";" + _fecha + ";" + _cantidad + ";";
                    _archivo.WriteLine(cabecera);

                    for (int i = 1; i <= senial.CantidadValores(); i++)
                    {
                        _linea_dato = i.ToString() + ";" + senial.ObtenerValor(i - 1).ToString() + ";";
                        _archivo.WriteLine(_linea_dato);
                    }

                    this.Trazar(senial, "Se guardo la señal");
                    this.Auditar(senial, senial.GetType().ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                this.Trazar(senial, e.Message);
            }
        }
开发者ID:vvalotto,项目名称:MiRepositorio,代码行数:31,代码来源:RepositorioArchivo.cs

示例12: Log

 public static void Log(LogFormat log, string fileName)
 {
     string filePath = string.Format("{0}{1}.csv", _logPath, fileName);
     bool fileExists = false;
     lock (lockMe)
     {
         if (File.Exists(filePath))
         {
             fileExists = true;
         }
         using (StreamWriter sw = new StreamWriter(filePath, true))
         {
             if (!fileExists)
             {
                 sw.WriteLine("IN DATE TIME,FlawID,FlawName,Flaw Y value(M),Flaw X value(M),JobID,OUT DATA,TYPE,Flaw Y value(mm),Flaw X value(mm),OUT DATA TIME,STATUS");
             }
             string output = string.Format("{0},{1},,{2},{3},{4}",
                 log.InputDateTime,
                 log.InputData,
                 log.OutputData,
                 log.OutputDateTime,
                 log.Status);
             sw.WriteLine(output);
             sw.Close();
         }
     }
 }
开发者ID:andyyou,项目名称:ccd_data_converter,代码行数:27,代码来源:WriteHelper.cs

示例13: saveData

 private void saveData()
 {
     TextWriter tw = new StreamWriter("penny.settings");
     if (checkBox1.Checked) tw.WriteLine("Enabled");
     else tw.WriteLine("Disabled");
     tw.Close();
 }
开发者ID:zadark,项目名称:par,代码行数:7,代码来源:PennyForm1.cs

示例14: GenerateIntoClass

        public static void GenerateIntoClass(
            String targetFile, String @namespace, String classDeclaration, Action<StringBuilder> logic)
        {
            var buffer = new StringBuilder();
            logic(buffer);

            using (var targetFileWriter = new StreamWriter(targetFile))
            {
                targetFileWriter.WriteLine(Constants.CodegenDisclaimer);
                targetFileWriter.WriteLine();

                var textGeneratedIntoClass = typeof(Helpers).Assembly.ReadAllText("Truesight.TextGenerators.Core.TextGeneratedIntoClass.template");
                textGeneratedIntoClass = textGeneratedIntoClass
                    .Replace("%NAMESPACE_NAME%", @namespace)
                    .Replace("%CLASS_DECLARATION%", classDeclaration)
                    .Replace("%GENERATED_TEXT%", buffer.ToString());

                if (classDeclaration.Contains("enum") || classDeclaration.Contains("interface"))
                {
                    textGeneratedIntoClass = textGeneratedIntoClass
                        .Replace("    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]" + Environment.NewLine, "");
                }

                targetFileWriter.Write(textGeneratedIntoClass);
            }
        }
开发者ID:xeno-by,项目名称:truesight-lite,代码行数:26,代码来源:Helpers.cs

示例15: Delete

        public bool Delete(Range range)
        {
            if (range.LineRange.Length == 0)
            {
                return true;
            }

            string fileContents = File.ReadAllText(_filename);

            using (StringReader reader = new StringReader(fileContents))
            using (TextWriter writer = new StreamWriter(File.Open(_filename, FileMode.Create)))
            {
                string lineText;
                if (SeekTo(reader, writer, range, out lineText))
                {
                    writer.WriteLine(lineText.Substring(0, range.LineRange.Start) + lineText.Substring(range.LineRange.Start + range.LineRange.Length));
                }

                lineText = reader.ReadLine();

                while (lineText != null)
                {
                    writer.WriteLine(lineText);
                    lineText = reader.ReadLine();
                }
            }

            return true;
        }
开发者ID:yannduran,项目名称:ProjectTaskRunner,代码行数:29,代码来源:FileTextUtil.cs


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