jueves, 6 de septiembre de 2007

How to create a file .txt with C#

Its very easy creates a file .txt using Visual C#, in order to use the normal references like:

using System.Text;
using System.IO;
Let’s begin:
private void create_file()
{

string fileName = Application.StartupPath.Substring(0, 2) + "\\My File.txt";
//A string with the drive where our application is running
//(in my own, the drive C:) and the name of the file .txt
//(check thats necessary the double '\\')
StreamWriter writer = File.CreateText(fileName);
//Lets use the StreamWriter whos going to help us to write in the file .txt
//and is equal to the object File and the method CreateText with
//the name of our file....the string fileName

writer.WriteLine(""Greetings from Poza Rica, Ver., Mexico");
//With writer we may write a line in the file
writer.WriteLine("");
//I use this to create a line blank

writer.WriteLine("Im Dr. Omm");
writer.WriteLine("");

writer.Close();
//Finally, we close the writer

}
I hope this be hepful to somebody...and sorry by my english
Dr. Omm


2 comentarios:

Anónimo dijo...

Hy how ARE YOU?

QUIENES USAN ESTA PAGINA... ME GUSTARIA SABER...

PUEDO SUBIR ALGO MAS QUE COMENTARIOS??//

Dr Omm dijo...

Hola que tal:
Saludos desde Poza Rica Ver., México
La verdad...este es un Blog creado por Mauricio Moo Aguilar, donde de vez en cuando se suben cosas al parecer interesantes.
El servicio es a través de Blogger, que ofrece gratuitamente a cualquier persona tener su blog y subir comentarios, imagenes, videos, y algunos otros servicios como encuestas, vinculos a otras webs, anuncios y códigos HTML externos.
Si lo deseas, puedes crear tu propio blog y poner lo que tu deseas. Si quieres publicar en mi blog (http://mauriciomoo.blogspot.com), mandame a mi correo el material y yo lo subire lo antes posible.
Saludos
Dr. Omm