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


C# System.IO.StreamWriter.WriteLine方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            var rand = new Random();
            //changing eps
            
            System.IO.StreamWriter file = new System.IO.StreamWriter("d:\\test.txt");
            file.WriteLine("changing eps");
            file.WriteLine("n eps time");
          
            for (int i = 100; i < 30000; i += 5000)
            {
                int[] t = new int[i];
                for (int k = 0; k < i; k++)
                {
                    t[k] = rand.Next(100);
                }
                for (double j = 0.5; j >= 0.05; j -= 0.05)
                {
                    Console.WriteLine(string.Format("{0} {1}", i, j));
                    var ptas = new PTAS.Repo.Ptas(t, j);
                    long time = 0;
                    for (int p = 0; p < 3; p++)
                    {
                        time += ptas.ptasFunction();
                    }
                    file.WriteLine(string.Format("{0} {1} {2}", i, j, time/3.0));
                }
            }

            file.Close();            
        }
开发者ID:w4-pwr,项目名称:studia,代码行数:31,代码来源:Program.cs

示例2: UpdateCache

        public static void UpdateCache(string folderPath, Dictionary<string, PMetaData> data)
        {
            if(data.Count > 0) 
            {
                System.IO.FileInfo info;
                if (System.IO.File.Exists(folderPath + @"\" + PICASA_FILE))
                {
                    info = new System.IO.FileInfo(folderPath + @"\" +PICASA_FILE);
                    info.Attributes = System.IO.FileAttributes.Normal;
                }

                using (System.IO.StreamWriter writer = new System.IO.StreamWriter(folderPath + @"\" + PICASA_FILE))
                {
                    foreach (var item in data)
                    {
                        if (item.Value.Keywords.Count > 0 || item.Value.RawData.Count > 0)
                        {
                            writer.WriteLine(string.Format("[{0}]", System.IO.Path.GetFileName(item.Key)));                            
                            string tags = string.Join(",", item.Value.Keywords.ToArray());

                            writer.WriteLine(string.Format("keywords={0}", tags));

                            foreach (var raw in item.Value.RawData)
                                writer.WriteLine(string.Format("{0}={1}", raw.Key, raw.Value));
                        }
                    }
                }
                info = new System.IO.FileInfo(folderPath + @"\" + PICASA_FILE);
                info.Attributes = System.IO.FileAttributes.Hidden;
            }
        }
开发者ID:Prashant-Jonny,项目名称:phever,代码行数:31,代码来源:PicasaHelper.cs

示例3: ExportCentroidsDict2TXT

        /// <summary>
        /// ExportCentroidsDict2TXT
        /// </summary>
        /// <param name="dictionary"></param>
        /// <param name="exportFileName"></param>
        public void ExportCentroidsDict2TXT(Dictionary<string, string> dictionary, 
            string exportFileName,
            Engine.AppEngine.ProjectionUnits projUnits,
            Boolean includeAreaPerimeter)
        {
            System.IO.TextWriter textWriter = new System.IO.StreamWriter(exportFileName);

              if (projUnits == Engine.AppEngine.ProjectionUnits.Geometric){
            if (includeAreaPerimeter == true)
            {
              textWriter.WriteLine("AreaId,CoordX,CoordY,Area,Perimeter");
            }
            else
            {
              textWriter.WriteLine("AreaId,CoordX,CoordY");
            }
              }
              else {
            if (includeAreaPerimeter == true)
            {
              textWriter.WriteLine("AreaId,Lat,Lon,Area,Perimeter");
            }
            else
            {
              textWriter.WriteLine("AreaId,Lat,Lon");
            }
              } // End if

              foreach (var dictItem in dictionary)
              {
            textWriter.WriteLine(dictItem.Value);
              } //End Foreach

              textWriter.Close();
        }
开发者ID:ZoneDesignSystems,项目名称:zds,代码行数:40,代码来源:OutputTools.cs

示例4: Main

        static void Main(string[] args)
        {
            System.IO.StreamWriter outputFile = new System.IO.StreamWriter(@"c:\VisualStudioOhjelmointi\tv.txt");

            TV tv1 = new TV { ShowName = "Uutiset", Channel = "Yle TV1", StartTime = "20.30", EndTime = "20.50", Info = "Illan uutislähetys" };
            outputFile.WriteLine(tv1);

            TV tv2 = new TV { ShowName = "Kymmenen uutiset", Channel = "MTV3", StartTime = "22.00", EndTime = "22.20", Info = "Illan pääuutislähetys" };
            outputFile.WriteLine(tv2);

            TV tv3 = new TV { ShowName = "Urheilua", Channel = "Yle TV2", StartTime = "14.30", EndTime = "16.50", Info = "Urheilua suorana lähetyksenä" };
            outputFile.WriteLine(tv3);

            outputFile.Close();

            try
            {
                string tvshows = System.IO.File.ReadAllText(@"c:\VisualStudioOhjelmointi\tv.txt");
                Console.WriteLine(tvshows);
            }
            catch (System.IO.FileNotFoundException)
            {
                Console.WriteLine("File not found!!!");
            }
        }
开发者ID:KimmoOinonen,项目名称:Demo07,代码行数:25,代码来源:Program.cs

示例5: UpdateCache

        public static void UpdateCache(string folderPath, Dictionary<string, PMetaData> datas)
        {
            if (datas.Count > 0)
            {                
                System.IO.FileInfo info;
                if (System.IO.File.Exists(folderPath + @"\" + GENTLE_FILE))
                {
                    info = new System.IO.FileInfo(folderPath + @"\" + GENTLE_FILE);
                    info.Attributes = System.IO.FileAttributes.Normal;
                }

                using (System.IO.StreamWriter writer = new System.IO.StreamWriter(folderPath + @"\"  + GENTLE_FILE))
                {
                    foreach (var item in datas)
                    {
                        writer.WriteLine(string.Format("[{0}]", System.IO.Path.GetFileName(item.Key)));
                        writer.WriteLine(string.Format("hash={0}", item.Value.Hash));
                        writer.WriteLine(string.Format("keywords={0}", string.Join(",", item.Value.Keywords.ToArray())));                        
                        writer.WriteLine(string.Format("updated={0}", item.Value.Updated));                       
                    }
                }

                info = new System.IO.FileInfo(folderPath + @"\" + GENTLE_FILE);
                info.Attributes = System.IO.FileAttributes.Hidden;
            }
        }
开发者ID:Prashant-Jonny,项目名称:phever,代码行数:26,代码来源:GHelper.cs

示例6: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Лабораторная работа по численным методам №6. Формула Гаусса");
            Console.WriteLine("Задача №8.5: [1.2;2](x-0.5)dx/((x^2-1)^1/2)\n");
            double Integral = 0;
            double a = 1.2, b = 2;
            double[,] AandT = new double[2,5];
            AandT[0, 0] = 0.236927;
            AandT[0, 1] = 0.478629;
            AandT[0, 2] = 0.568889;
            AandT[0, 3] = 0.478629;
            AandT[0, 4] = 0.236927;
            AandT[1, 0] = -0.906180;
            AandT[1, 1] = -0.538459;
            AandT[1, 2] = 0;
            AandT[1, 3] = 0.538469;
            AandT[1, 4] = 0.906180;

            System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Lab6.txt");
            for (int i = 0; i < 5; ++i)
            {
                Integral += AandT[0, i] * f(((a + b) / 2) + ((b - a) / 2) * AandT[1, i]);
                Console.WriteLine("t{0} = {1:0.000000}, A{0} = {2:0.000000}, Summ(I){0} = {3:0.00000}", i + 1, AandT[1, i], AandT[0, i], Integral);
                file.WriteLine("t{0} = {1:0.000000}, A{0} = {2:0.000000}, Summ(I){0} = {3:0.00000}", i + 1, AandT[1, i], AandT[0, i], Integral);
            }
            Integral *= (b - a) / 2;
            file.WriteLine("Ответ: " + Integral);
            Console.WriteLine("\nПриближенное значение интеграла I = {0:0.00000}",Integral);
            file.Close();
        }
开发者ID:Ruxton92,项目名称:Numerical-methods,代码行数:30,代码来源:Program.cs

示例7: reClient

 public void reClient()
 {
     string listenerIp = WebService.ContentValue("Listener", "ListenerIp", WebService.WASConfigPath);//监听的IP地址
     string listenerPort = WebService.ContentValue("Listener", "ListenerPort", WebService.WASConfigPath);//监听的端口号
     string DataSourceIpOrPortA = WebService.ContentValue("DataSourceA", "DataServiceA", WebService.WASConfigPath);//数据源的IP和端口A
     string DataSourceIpOrPortB = WebService.ContentValue("DataSourceB", "DataServiceB", WebService.WASConfigPath);//数据源的IP和端口B
     using (System.IO.StreamWriter sws = new System.IO.StreamWriter("C:\\KIOSKlog2.txt", true))
     {
         sws.WriteLine(DataSourceIpOrPortA);
         sws.WriteLine(DataSourceIpOrPortB);
     }
     IPAddress ip = IPAddress.Parse(listenerIp);//IP地址
     listener = new TcpListener(ip, Convert.ToInt32(listenerPort));//使用本机Ip地址和端口号创建一个System.Net.Sockets.TcpListener的实例
     try
     {
         listener.Start(); ////监听客户端的请求:开始侦听
     }
     catch (Exception)
     {
         return;
     }
     try
     {
         while (true) //接收多个客户端
         {
             client = listener.AcceptTcpClient();//获取单一客户端连接
             agent = new Agent(client, client.GetStream(), DataSourceIpOrPortA, DataSourceIpOrPortB);
             ziThread = new Thread(agent.dele);//单一客户端可以发送多条请求
             ziThread.Start(null);
         }
     }
     catch (SocketException)
     {
     }
 }
开发者ID:find-life,项目名称:KIOSKWindowService,代码行数:35,代码来源:KIOSKService.cs

示例8: SavePeople

        // Save people from text file
        public bool SavePeople()
        {
            System.IO.TextWriter textOut = null;
            try
            {
                System.IO.File.WriteAllText(filename, string.Empty);
                textOut = new System.IO.StreamWriter(filename);
                textOut.WriteLine(TopFivePeople.Count());
                foreach (PersonDetails People in TopFivePeople) // Save all the people
                {
                    textOut.WriteLine(People.NameGetSet);
                    textOut.WriteLine(People.ScoreGetSet);
                }

            }
            catch
            {
                return false;
            }
            finally
            {
                if (textOut != null) textOut.Close();
            }

            return true;
        }
开发者ID:ADWilsonCode,项目名称:Full-Fruity-Squash,代码行数:27,代码来源:HighScore.cs

示例9: Main

        static void Main(string[] args)
        {
            double start = -4;
            double end = 6;
            double factor = 65535 / Math.Exp(end);
            int steps = 100;
            double step = (end - start) / (steps - 1);
            int i;
            int value;

            System.IO.StreamWriter file = new System.IO.StreamWriter(@"logvec.h");
            System.IO.StreamWriter file2 = new System.IO.StreamWriter(@"logvec.txt");

            file.Write("static const int logvec[] = { 0x0000,");
            for (i = 0; i < 100; i++)
            {
                if ((i % 10) == 0)
                {
                    file.WriteLine();
                    file.Write("\t");
                }
                value = (int)Math.Floor(Math.Exp(start) * factor);
                start += step;
                file2.Write("{0}, ", value);
                file.Write ("0x{0:X4}, ", value);
            }
            file.WriteLine();
            file.WriteLine("};");

            file.Close();
            file2.Close();
        }
开发者ID:PontusO,项目名称:waterboy,代码行数:32,代码来源:Program.cs

示例10: Run

        public void Run()
        {
            var ext = System.IO.Path.GetExtension(m_targetpath);
            var module = m_options.CompressionModule;

            if (ext != module)
                m_targetpath = m_targetpath + "." + module;

            if (System.IO.File.Exists(m_targetpath))
                throw new Exception(string.Format("Output file already exists, not overwriting: {0}", m_targetpath));

            if (!System.IO.File.Exists(m_options.Dbpath))
                throw new Exception(string.Format("Database file does not exist: {0}", m_options.Dbpath));

            m_result.AddMessage("Scrubbing filenames from database, this may take a while, please wait");

            using(var tmp = new Library.Utility.TempFile())
            {
                System.IO.File.Copy(m_options.Dbpath, tmp, true);
                using(var db = new LocalBugReportDatabase(tmp))
                {
                    m_result.SetDatabase(db);
                    db.Fix();
                }

                using(var cm = DynamicLoader.CompressionLoader.GetModule(module, m_targetpath, m_options.RawOptions))
                {
                    using(var cs = cm.CreateFile("log-database.sqlite", Duplicati.Library.Interface.CompressionHint.Compressible, DateTime.UtcNow))
                    using(var fs = System.IO.File.Open(tmp, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite))
                        Library.Utility.Utility.CopyStream(fs, cs);

                    using(var cs = new System.IO.StreamWriter(cm.CreateFile("system-info.txt", Duplicati.Library.Interface.CompressionHint.Compressible, DateTime.UtcNow)))
                    {
                        cs.WriteLine("Duplicati: {0} ({1})", System.Reflection.Assembly.GetEntryAssembly().FullName, System.Reflection.Assembly.GetExecutingAssembly().FullName);
                        cs.WriteLine("OS: {0}", Environment.OSVersion);
                        cs.WriteLine("Uname: {0}", Duplicati.Library.Utility.Utility.UnameAll);

                        cs.WriteLine("64bit: {0} ({1})", Environment.Is64BitOperatingSystem, Environment.Is64BitProcess);
                        cs.WriteLine("Machinename: {0}", Environment.MachineName);
                        cs.WriteLine("Processors: {0}", Environment.ProcessorCount);
                        cs.WriteLine(".Net Version: {0}", Environment.Version);
                        cs.WriteLine("Mono: {0} ({1}) ({2})", Duplicati.Library.Utility.Utility.IsMono, Duplicati.Library.Utility.Utility.MonoVersion, Duplicati.Library.Utility.Utility.MonoDisplayVersion);

                        Type sqlite = null;
                        string sqliteversion = "";

                        try { sqlite = Duplicati.Library.SQLiteHelper.SQLiteLoader.SQLiteConnectionType; }
                        catch { }

                        if (sqlite != null)
                        {
                            try { sqliteversion = (string)sqlite.GetProperty("SQLiteVersion").GetValue(null, null); }
                            catch { }

                            cs.WriteLine("SQLite: {0} - {1}", sqliteversion, sqlite.FullName);
                        }
                    }
                }
            }
        }
开发者ID:Berimor66,项目名称:duplicati,代码行数:60,代码来源:CreateBugReportHandler.cs

示例11: WriteLog

 public static void WriteLog(Exception ex)
 {
     //just in case: we protect code with try.
     try
     {
         string filename = m_baseDir
             + GetFilenameYYYMMDD("_LOG", ".log");
         System.IO.StreamWriter sw = new System.IO.StreamWriter(filename, true);
     //				XElement xmlEntry = new XElement("logEntry",
     //				                                 new XElement("Date", System.DateTime.Now.ToString()),
     //				                                 new XElement("Exception",
     //				             new XElement("Source", ex.Source),
     //				             new XElement("Message", ex.Message),
     //				             new XElement("Stack", ex.StackTrace)
     //				             )//end exception
     //				                                 );
         sw.WriteLine(string.Format("{0} {1} {2}\r\n{3}",System.DateTime.Now.ToString(), ex.Source, ex.Message, ex.StackTrace));
         //has inner exception?
         if (ex.InnerException != null)
         {
     //					xmlEntry.Element("Exception").Add(
     //					                                  new XElement("InnerException",
     //					             new XElement("Source", ex.InnerException.Source),
     //					             new XElement("Message", ex.InnerException.Message),
     //					             new XElement("Stack", ex.InnerException.StackTrace))
     //					                                  );
             sw.WriteLine(string.Format("{0} {1} {2}\r\n{3}",System.DateTime.Now.ToString(),
                 ex.InnerException.Source, ex.InnerException.Message, ex.InnerException.StackTrace));
         }
         //sw.WriteLine(xmlEntry);
         sw.Close();
     } catch (Exception) {}
 }
开发者ID:claytantor,项目名称:shadow-haven-unity,代码行数:33,代码来源:ReallySimpleLogger.cs

示例12: SauvegarderCarte

        public void SauvegarderCarte(List<Tuile>[,] tuileArray, String asset)
        {
            ecrireCarte = new System.IO.StreamWriter(asset);

            int width = tuileArray.GetLength(0);
            int height = tuileArray.GetLength(1);

            ecrireCarte.WriteLine(width);
            ecrireCarte.WriteLine(height);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    string str = "";

                    foreach (Tuile tuile in tuileArray[x, y])
                    {
                        str += tuile.type;
                        if (tuile.hauteur < 10)
                            str += "0";
                        str += tuile.hauteur;
                    }

                    ecrireCarte.WriteLine(str);

                }
            }

            ecrireCarte.Close();

            Console.WriteLine("CARTE SAUVEGARDEE");
        }
开发者ID:MetaCorp,项目名称:PowerOfZonhya,代码行数:33,代码来源:MoteurSysteme.cs

示例13: MakePackage

        MakePackage()
        {
            var packageDir = Graph.Instance.ProcessState.WorkingDirectory;
            var bamDir = System.IO.Path.Combine(packageDir, BamSubFolder);
            if (System.IO.Directory.Exists(bamDir))
            {
                throw new Exception("A Bam package already exists at {0}", packageDir);
            }

            var packageNameArgument = new Options.PackageName();
            var packageName = CommandLineProcessor.Evaluate(packageNameArgument);
            if (null == packageName)
            {
                throw new Exception("No name was defined. Use {0} on the command line to specify it.", (packageNameArgument as ICommandLineArgument).LongName);
            }

            var packageVersion = CommandLineProcessor.Evaluate(new Options.PackageVersion());
            var definition = new PackageDefinition(bamDir, packageName, packageVersion);

            System.IO.Directory.CreateDirectory(bamDir);
            definition.Write();

            var scriptsDir = System.IO.Path.Combine(bamDir, ScriptsSubFolder);
            System.IO.Directory.CreateDirectory(scriptsDir);

            var initialScriptFile = System.IO.Path.Combine(scriptsDir, packageName) + ".cs";
            using (System.IO.TextWriter writer = new System.IO.StreamWriter(initialScriptFile))
            {
                writer.WriteLine("using Bam.Core;");
                writer.WriteLine("namespace {0}", packageName);
                writer.WriteLine("{");
                writer.WriteLine("    // write modules here ...");
                writer.WriteLine("}");
            }
        }
开发者ID:knocte,项目名称:BuildAMation,代码行数:35,代码来源:PackageUtilities.cs

示例14: logPoints

        public void logPoints(Shape currentShape, bool success, int curSet, int curSeq, int shapeInd)
        {
            // Append new text to an existing file.
            // The using statement automatically flushes AND CLOSES the stream and calls
            // IDisposable.Dispose on the stream object.
            Console.WriteLine("Logging points...");

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileName, true))
            {
                file.WriteLine("Intended Shape: {0}", currentShape.name);
                if (success)
                {
                    file.WriteLine("Success");
                }
                else
                {
                    file.WriteLine("Failure");
                }
                file.WriteLine(points.Count);
                for (int i = 0; i < points.Count; i++)
                {
                    file.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},{8}", i, points[i].X, points[i].Y, points[i].stroke, points[i].time, points[i].pressure,curSet,curSeq,shapeInd);
                }
            }
            Console.WriteLine("Done logging points.");
        }
开发者ID:hainesricky,项目名称:624-Final,代码行数:26,代码来源:TemplateRecognizer.cs

示例15: endCurrentPeriod

        public static bool endCurrentPeriod(string username, string name)
        {
            try
            {
                string clean = "";
                string[] lines;

                lines = System.IO.File.ReadAllLines("Data\\" + username + ".current");
                int mlz = 0;
                int exp = 0;
                for (int i = 0; i < lines.Length; i++)
                {
                    if (i % 2 == 0)
                    {
                        if (lines[i].StartsWith("$"))
                            exp += Int16.Parse(lines[i].TrimStart('$'));
                        else
                            mlz += Int16.Parse(lines[i]);
                    }
                }
                clean += "$" + exp + ", " + mlz + " mi.";

                System.IO.StreamWriter file = new System.IO.StreamWriter("Data\\" + username + ".archive", true);
                file.WriteLine(clean);
                file.WriteLine(name);
                file.Close();
                file = new System.IO.StreamWriter("Data\\" + username + ".current", false);
                file.Close();
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
开发者ID:byronic,项目名称:myleage-server,代码行数:35,代码来源:DataManager.cs


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