C# Source Codes: Write Text ( StreamWriter )

Thursday, December 24, 2009

Write Text ( StreamWriter )






Source Code : Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;


namespace WriteText
{
public partial class Form1 : Form
{
string Path;
DirectoryInfo D;
public Form1()
{
InitializeComponent();

D = new DirectoryInfo(Environment.CurrentDirectory);
Path = D.FullName;
}

private void button1_Click(object sender, EventArgs e)
{
FileInfo FI = new FileInfo("MyText.txt");
StreamWriter SW = FI.CreateText();

SW.WriteLine(textBox1.Text);
SW.Close();

MessageBox.Show("finished to write your text in \"MyText.txt\" !\n" + "your text file Directory = " + Path);

}

}
}




Source Code : Form1.Designer.cs

namespace WriteText
{
partial class Form1
{
///
/// Required designer variable.
///

private System.ComponentModel.IContainer components = null;

///
/// Clean up any resources being used.
///


protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.ForeColor = System.Drawing.Color.Red;
this.label1.Location = new System.Drawing.Point(12, 33);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(81, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Enter your text :";
//
// button1
//
this.button1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.button1.Location = new System.Drawing.Point(76, 79);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(146, 35);
this.button1.TabIndex = 2;
this.button1.Text = "Write Your Text";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.ForeColor = System.Drawing.Color.Blue;
this.textBox1.Location = new System.Drawing.Point(93, 30);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(179, 20);
this.textBox1.TabIndex = 3;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new System.Drawing.Size(284, 126);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = " Write Text";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
}
}





Download :

exe
http://sites.google.com/site/ogremyfiles/WriteText_EXE.rar
Source Code
http://sites.google.com/site/ogremyfiles/WriteText_SourceCode.rar



Designed by : Ogre