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


C# StreamWriter.Write方法代码示例

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


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

示例1: AppendResultsToFile

        public void AppendResultsToFile(String Name, double TotalTime)
        {
            FileStream file;
            file = new FileStream(Name, FileMode.Append, FileAccess.Write);
            StreamWriter sw = new StreamWriter(file);

            sw.Write("***************************************\n");

            sw.Write("Total  | No Subs| %Total |%No Subs| Name\n");

            foreach (CNamedTimer NamedTimer in m_NamedTimerArray)
            {
                if (NamedTimer.GetTotalSeconds() > 0)
                {
                    String OutString;

                    OutString = String.Format("{0:0.0000}", NamedTimer.GetTotalSeconds())
                        + " | " + String.Format("{0:0.0000}", NamedTimer.GetTotalSecondsExcludingSubroutines())
                        + " | " + String.Format("{0:00.00}", System.Math.Min(99.99, NamedTimer.GetTotalSeconds() / TotalTime * 100)) + "%"
                        + " | " + String.Format("{0:00.00}", NamedTimer.GetTotalSecondsExcludingSubroutines() / TotalTime * 100) + "%"
                        + " | "
                        + NamedTimer.m_Name;

                    OutString += " (" + NamedTimer.m_Counter.ToString() + ")\n";
                    sw.Write(OutString);
                }
            }

            sw.Write("\n\n");

            sw.Close();
            file.Close();
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:33,代码来源:Execution+Timer.cs

示例2: Start

    // Use this for initialization
    void Start()
    {
        string fileName = "drives.txt";
        string outFileName = "drivesOut.txt";
        StreamReader sr = new StreamReader(fileName);
        StreamWriter sw = new StreamWriter(outFileName);

        string[] content = File.ReadAllLines(fileName);

        for (int i = 0; i < content.Length; i++) {
            string[] tokens = content[i].Split('\t');

            sw.WriteLine("INSERT INTO driveDataRCTAMAN(userId, driveInd, speed, v0, v1, ti, texp, tval, t0, t1, hr, hf, squash, wb, wx, wt,wf, et, ef, d,  tr, tf, encSpr0, sinRis0, retAdv0, encSpr1, sinRis1, retAdv1, continuity, bias, armLX, armLY,	armLZ,	armRX,	armRY,	armRZ)");
            sw.Write("VALUES (");

            for (int j = 0; j < tokens.Length; j++) {
                sw.Write("'" + tokens[j] + "'");
                if (j < tokens.Length - 1)
                    sw.Write(",");

            }
            sw.WriteLine(");");

        }

        sw.Close();
        sr.Close();

        EditShapes();
    }
开发者ID:BibleUs,项目名称:Personality,代码行数:31,代码来源:EditDriveData.cs

示例3: ControlFile

 // カメラなどの座標が書き込まれた行を力技で強引に編集
 void ControlFile(int n)
 {
     string tmpFile = Path.GetTempFileName();
     using (StreamReader sr = new StreamReader(PATH))
     using (StreamWriter sw = new StreamWriter(tmpFile))
     {
         int ReferLine = 0;  // 参照する行
         while (sr.Peek() > -1)
         {
             string line = sr.ReadLine();    // 読み込んだ一行
             ++ReferLine;
             if (1 == ReferLine)
             {
                 sw.Write(n);
             }
             else if (n + 3 == ReferLine)
             {
                 sw.Dispose();
             }
             else
             {
                 sw.Write("\n" + line);
             }
             //ReferLine++;
         }
         //閉じる
         sr.Close();
         sw.Close();
     }
     //入れ替え
     File.Copy(tmpFile, PATH, true);
     File.Delete(tmpFile);
 }
开发者ID:backspace229,项目名称:NUIMolecularModel,代码行数:34,代码来源:PrintPosition.cs

示例4: SendData

 private void SendData(string data)
 {
     StreamWriter writer = new StreamWriter(client.GetStream());
     writer.Write(44);
     writer.Write(55);
     writer.Flush();
 }
开发者ID:HiroLord,项目名称:VGDesign,代码行数:7,代码来源:Networking.cs

示例5: EditShapes

    void EditShapes()
    {
        string fileName = "shapes.txt";
        string outFileName = "shapesOut.txt";
        StreamReader sr = new StreamReader(fileName);
        StreamWriter sw = new StreamWriter(outFileName);

        string[] content = File.ReadAllLines(fileName);

        for (int i = 0; i < content.Length; i++) {
            string[] tokens = content[i].Split('\t');

            sw.WriteLine("INSERT INTO shapeDataRCTAMAN(userId, shapeInd, head, neck, spine, spine1, shouldersX, shouldersY, shouldersZ, claviclesX, claviclesY, claviclesZ, pelvisLX, pelvisRX, pelvisY, pelvisZ, kneeX, hipsX, toesX, spineLength)");
            sw.Write("VALUES (");

            for (int j = 0; j < tokens.Length; j++) {
                sw.Write("'" + tokens[j] + "'");
                if (j < tokens.Length - 1)
                    sw.Write(",");

            }
            sw.WriteLine(");");

        }

        sw.Close();
        sr.Close();
    }
开发者ID:BibleUs,项目名称:Personality,代码行数:28,代码来源:EditDriveData.cs

示例6: Main

 static void Main()
 {
     ulong P = 51839;
     ulong Q = 51913;
     ulong N = P*Q;
     
     ulong E = 1073741813;
     
     ulong D = 2138488109;
     
     ulong PhiN = (P-1)*(Q-1);
     
     ulong EPrime = 52741219;
     ulong NPrime = 3125033603;
    
    
    //String to Encrypt
    string Text = "Hello D.E.A.R. I am student 20509293. This is my little secret: 51839 and 51913. Not so far from New York, Titanic ignored iceberg warnings and blazed onward, struck an iceberg, then sank less than three hours later in the North Atlantic. This marked the death of the Unsinkable ship and the beginning of new safety precautions for sea travel. The Titanic, also known to be the greatest ship made in the history of ships. I LOVE ECE 103, I LOVE ECE 103, I LOVE ECE 103, I LOVE ECE 103, I LOVE ECE 103. WATER WATER WATER --- LOO LOO LOO. Waterloo ROCKS!!!!!...."; 
    
    //Split String into 4 Character Chunks
    string[] SplitText = SplitInChunks(Text, 4).ToArray();
    
    StreamWriter inStream = new StreamWriter("20509293.txt");
    inStream.Write(String.Format("{0} {1} {2} ", N, E, SplitText.GetLength(0)));
    
    foreach(string s in SplitText)
    {
         inStream.Write(String.Format("{0} ", Encrypt(ConvertedBits(s), D, N, EPrime, NPrime)));
         inStream.Flush();
    }
    
    Console.WriteLine("20509293.txt Has Been Created With Encrypted Text");
    
   
 }
开发者ID:anpaulin,项目名称:RSA-Text-Encryption,代码行数:35,代码来源:RSA_Encrypt.cs

示例7: WriteLogFile

    public static void WriteLogFile(String input, string filePath)
    {
        //定义文件信息对象
        FileInfo finfo = new FileInfo(filePath);

        //判断文件是否存在以及是否大于2M
        if (finfo.Exists && finfo.Length > 2047500)
        {
            //删除该文件
            finfo.Delete();
        }
        //创建只写文件流
        using (FileStream fs = finfo.OpenWrite())
        {
            //根据上面创建的文件流创建写数据流
            StreamWriter w = new StreamWriter(fs);
            //设置写数据流的起始位置为文件流的末尾
            w.BaseStream.Seek(0, SeekOrigin.End);
            //写入“Log Entry : ”
            w.Write("\r\nLog Entry : ");
            //写入当前系统时间并换行
            w.Write("{0} {1} \r\n", DateTime.Now.ToLongTimeString(),
                DateTime.Now.ToLongDateString());
            //写入日志内容并换行
            w.Write(input + "\r\n");
            //写入------------------------------------“并换行
            w.Write("------------------------------------\r\n");
            //清空缓冲区内容,并把缓冲区内容写入基础流
            w.Flush();
            //关闭写数据流
            w.Close();
        }
    }
开发者ID:lakeli,项目名称:shizong,代码行数:33,代码来源:Logger.cs

示例8: Main

    public static void Main()
    {
        const string OUTPUTFILENAME = @"C:\Temp\WindowsTimeZoneInfo.txt";

          DateTimeFormatInfo dateFormats = CultureInfo.CurrentCulture.DateTimeFormat;
          ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
          StreamWriter sw = new StreamWriter(OUTPUTFILENAME, false);

          foreach (TimeZoneInfo timeZone in timeZones)
          {
         bool hasDST = timeZone.SupportsDaylightSavingTime;
         TimeSpan offsetFromUtc = timeZone.BaseUtcOffset;
         TimeZoneInfo.AdjustmentRule[] adjustRules;
         string offsetString;

         sw.WriteLine("ID: {0}", timeZone.Id);
         sw.WriteLine("   Display Name: {0, 40}", timeZone.DisplayName);
         sw.WriteLine("   Standard Name: {0, 39}", timeZone.StandardName);
         sw.Write("   Daylight Name: {0, 39}", timeZone.DaylightName);
         sw.Write(hasDST ? "   ***Has " : "   ***Does Not Have ");
         sw.WriteLine("Daylight Saving Time***");
         offsetString = String.Format("{0} hours, {1} minutes", offsetFromUtc.Hours, offsetFromUtc.Minutes);
         sw.WriteLine("   Offset from UTC: {0, 40}", offsetString);
         adjustRules = timeZone.GetAdjustmentRules();
         sw.WriteLine("   Number of adjustment rules: {0, 26}", adjustRules.Length);
         if (adjustRules.Length > 0)
         {
            sw.WriteLine("   Adjustment Rules:");
            foreach (TimeZoneInfo.AdjustmentRule rule in adjustRules)
            {
               TimeZoneInfo.TransitionTime transTimeStart = rule.DaylightTransitionStart;
               TimeZoneInfo.TransitionTime transTimeEnd = rule.DaylightTransitionEnd;

               sw.WriteLine("      From {0} to {1}", rule.DateStart, rule.DateEnd);
               sw.WriteLine("      Delta: {0}", rule.DaylightDelta);
               if (! transTimeStart.IsFixedDateRule)
               {
                  sw.WriteLine("      Begins at {0:t} on {1} of week {2} of {3}", transTimeStart.TimeOfDay,
                                                                                transTimeStart.DayOfWeek,
                                                                                transTimeStart.Week,
                                                                                dateFormats.MonthNames[transTimeStart.Month - 1]);
                  sw.WriteLine("      Ends at {0:t} on {1} of week {2} of {3}", transTimeEnd.TimeOfDay,
                                                                                transTimeEnd.DayOfWeek,
                                                                                transTimeEnd.Week,
                                                                                dateFormats.MonthNames[transTimeEnd.Month - 1]);
               }
               else
               {
                  sw.WriteLine("      Begins at {0:t} on {1} {2}", transTimeStart.TimeOfDay,
                                                                 transTimeStart.Day,
                                                                 dateFormats.MonthNames[transTimeStart.Month - 1]);
                  sw.WriteLine("      Ends at {0:t} on {1} {2}", transTimeEnd.TimeOfDay,
                                                               transTimeEnd.Day,
                                                               dateFormats.MonthNames[transTimeEnd.Month - 1]);
               }
            }
         }
          }
          sw.Close();
    }
开发者ID:TaNhoSy,项目名称:zimbra-mirror,代码行数:60,代码来源:getWindowsTimezoneInfo.cs

示例9: SaveMap

	public IEnumerator SaveMap(string mapName, bool isItMap)
	{
		isSaving = true;
		yield return 0;

		GameObject main = (GameObject) GameObject.Find("MAP");
		uteTagObject[] allObjects = main.GetComponentsInChildren<uteTagObject>();
		string info = "";

		for(int i=0;i<allObjects.Length;i++)
		{
			if(i%2000==0) yield return 0;
			
			GameObject obj = (GameObject) ((uteTagObject)allObjects[i]).gameObject;
			string objGUID = ((uteTagObject)allObjects[i]).objGUID;
			bool objIsStatic = ((uteTagObject)allObjects[i]).isStatic;
			string layerName = ((uteTagObject)allObjects[i]).layerName;
			bool objTC = ((uteTagObject)allObjects[i]).isTC;
			string tcFamilyName = "-";

			if(obj.GetComponent<uteTcTag>())
			{
				tcFamilyName = ((uteTcTag) obj.GetComponent<uteTcTag>()).tcFamilyName;
			}

			string staticInfo = "0";
			string tcInfo = "0";

			if(objIsStatic)
				staticInfo = "1";

			if(objTC)
				tcInfo = "1";

			info += objGUID+":"+obj.transform.position.x+":"+obj.transform.position.y+":"+obj.transform.position.z+":"+((int)obj.transform.localEulerAngles.x)+":"+((int)obj.transform.localEulerAngles.y)+":"+((int)obj.transform.localEulerAngles.z)+":"+staticInfo+":"+tcInfo+":"+tcFamilyName+":"+layerName+":$";
		}

		string path;

		if(isItMap)
		{
			path = uteGLOBAL3dMapEditor.getMapsDir();
		}
		else
		{
			path = uteGLOBAL3dMapEditor.getPatternsDir();
		}

		StreamWriter sw = new StreamWriter(path+mapName+".txt");
		sw.Write("");
		sw.Write(info);
		sw.Flush();
		sw.Close();

		SaveMapSettings(mapName,isItMap);

		isSaving = false;

		yield return 0;
	}
开发者ID:gato0429,项目名称:GlobalGame2016,代码行数:60,代码来源:uteSaveMap.cs

示例10: Main

    static void Main()
    {
        //I will put the .txt files in the same directory as .cs file
        StreamReader firstReader = new StreamReader("../../FirstFile.txt");
        StreamReader secondReader = new StreamReader("../../secondFile.txt");
        StreamWriter ConcatenatedFile = new StreamWriter("../../ConcatenatedFile.txt", true);
        using (ConcatenatedFile)
        {
            using (firstReader)
            {
                string firstFile = firstReader.ReadToEnd();
                ConcatenatedFile.Write(firstFile);
            }
            using (secondReader)
            {
                string secondFile = secondReader.ReadToEnd();
                ConcatenatedFile.Write(secondFile);
            }
        }

        //print on the console the concatenated file
        StreamReader NewFile = new StreamReader("../../ConcatenatedFile.txt");
        string line = NewFile.ReadLine();
        while (line != null)
        {
            Console.WriteLine(line);
            line = NewFile.ReadLine();
        }
    }
开发者ID:novocob,项目名称:TelerikAcademy,代码行数:29,代码来源:ConcatenateTwoFiles.cs

示例11: exportHandler

    // What to do when the user wants to export a TeX file
    private void exportHandler(object sender, EventArgs e)
    {
        Stream stream;
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "SVG files|(*.svg";
        saveFileDialog.RestoreDirectory = true;

        if(saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            if((stream = saveFileDialog.OpenFile()) != null)
            {
                // Insert code here that generates the string of LaTeX
                //   commands to draw the shapes
                using(StreamWriter writer = new StreamWriter(stream))
                {
                    writer.Write("<?xml version='1.0' standalone='no'?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> <svg xmlns='http://www.w3.org/2000/svg' version='1.1'> ");

                    Visual visual = new VisualSVG(writer);

                    //Draw all shapes
                    foreach (Shape shape in shapes)
                    {
                        shape.visual = visual;

                        shape.Draw();
                    }

                    writer.Write("</svg>");
                }
            }
        }
    }
开发者ID:Tyskai,项目名称:ShapesOpdracht3,代码行数:34,代码来源:ShapeDrawing.cs

示例12: MeshToFile

	public static void MeshToFile(MeshFilter mf, string path) 
	{
		vertexOffset = 0;
		normalOffset = 0;
		uvOffset = 0;

		if(path.Contains(".obj"))
			path = path.Replace(".obj", "");

		string folder = path;
		string filename = Path.GetFileName(path);

		if(!Directory.Exists(folder))
			Directory.CreateDirectory(folder);

		Dictionary<string, ObjMaterial> materialList = new Dictionary<string, ObjMaterial>();

		using (StreamWriter sw = new StreamWriter(folder +"/" + filename + ".obj")) 
		{
			sw.Write("mtllib ./" + filename + ".mtl\n");

			sw.Write(MeshToString(mf, materialList));
		}

		MaterialsToFile(materialList, folder, filename);
	}
开发者ID:itubeasts,项目名称:I-eaT-U,代码行数:26,代码来源:EditorObjExporter.cs

示例13: MakeFileToRead

 private static void MakeFileToRead(String file,Boolean option)
 {
     using (StreamWriter write = new StreamWriter(file))
     {
         if (!option)
         {
             for (int i = 0; i < 20; i++)
             {
                 for (int j = 0; j < 20; j++)
                 {
                     write.Write(j);
                 }
                 write.WriteLine(i);
                 write.Flush();
             }
         }
         else
         {
             for (int i = 0; i < final.Length; i++)
             {
                 if (final[i] == '\n') { write.WriteLine(); }
                 else write.Write(final[i]);
                 write.Flush();
             }
         }
     }
 }
开发者ID:Bvaptsarov,项目名称:Homework,代码行数:27,代码来源:Program.cs

示例14: Main

    static void Main()
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        string inputPathOne = "..\\..\\Text1.txt";
        string inputPathTwo = "..\\..\\Text2.txt";
        string result = "..\\..\\Result.txt";

        StreamWriter writer = new StreamWriter(result);
        using (writer)
        {
            StreamReader readerOne = new StreamReader(inputPathOne);
            using (readerOne)
            {
                string textOne = readerOne.ReadLine();
                while (textOne != null)
                {
                    writer.Write(textOne);
                    textOne = readerOne.ReadLine();
                }
            }
            StreamReader readerTwo = new StreamReader(inputPathTwo);
            using (readerTwo)
            {
                string textTwo = readerTwo.ReadLine();
                while (textTwo != null)
                {
                    writer.Write(textTwo);
                    textTwo = readerTwo.ReadLine();
                }
            }
        }

        Console.WriteLine("Just finished!");
    }
开发者ID:AngataHristov,项目名称:AdvancedCSharp,代码行数:34,代码来源:ConcatenateTxtFiles.cs

示例15: MeshToFile

 public static void MeshToFile (MeshFilter mf, string filename, float scale)
 {
     using (StreamWriter sw = new StreamWriter(filename)) {
         sw.Write ("#VRML V2.0 utf8\r\n");
         sw.Write (MeshToString (mf, scale));
     }
 }
开发者ID:Avatarchik,项目名称:Unity,代码行数:7,代码来源:VrmlExporter.cs


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