Using File.CreateText to create a text file and return StreamWriter : StreamWriter « File Directory Stream « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » File Directory Stream » StreamWriter 
15.21.14.Using File.CreateText to create a text file and return StreamWriter
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.IO;


class MainClass
{
    public static void Main()
    {
        StreamWriter Writer;
        Writer = File.CreateText("TestResults.log");
        Writer.WriteLine("Test Results for Test Run XYZ; " + DateTime.Now);
        if (File.Exists("fileName"))
        {
            Writer.WriteLine("File Exists: Test Passed");
        }
        else
        {
            Writer.WriteLine("File Exists: Test Failed");
        }
        Writer.WriteLine("Test Completed for Test Run XYZ; " + DateTime.Now);
        Writer.Close();
    }
}
15.21.StreamWriter
15.21.1.new StreamWriter(fs, Encoding.UTF8)
15.21.2.Reading and Writing Files
15.21.3.Open a file using StreamWriter
15.21.4.Save string, decimal and char using FileStream and StreamWriter
15.21.5.Create StringWriter from StringBuilder
15.21.6.Using StreamWriter: write string
15.21.7.Using StreamWriter: write char
15.21.8.Using StreamWriter: Writes an Array of characters
15.21.9.Using StreamWriter: write a portion of an array
15.21.10.StreamWriter/Reader App
15.21.11.StringReader/Writer App
15.21.12.Stream Write with StreamWriter
15.21.13.Using statement and StreamWriter
15.21.14.Using File.CreateText to create a text file and return StreamWriter
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.