Wednesday, May 20, 2009

Universal Date Format For windows application in c#.NET

Date Format plays a major role in windows application development in c#.
Because by default, Its set to our Regional Settings's Date Format (Control Panel).If you change Regional Settings's Date Format then your windows application's Format will automatically gets changed.

If you design an application for single System means There is no problem.But If it's Multi User(LAN) & accessed from different system means problem will occur.because each system may have different date formats.

and By Default It set to US format mm/dd/yyyy.But in INDIA we need date in dd/mm/yyyy.so we have to change culture information of our application.Like Below

System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fr-FR");

Here,
FR refers FRANCE.
for INDIA we can set it as hi-IN(hindi),ta-IN(tamil) for each language.

Just add This Line in Main Form Loading Event.Then in entire Application All Date Conversion methods will have format as dd/mm/yyyy only.

If you want to set different culture info means you can add this line where you need to set a culture at run time.

And also if you retrieve date from a File or some where else as String then after that if you convert it into Date means,It will converted into dd/mm/yyyy format Only.

So we can set DATE FORMAT for entire windows application with the help of above culture settings.

Thank you.

Saturday, May 9, 2009

Silver Member in c# corner website

Today I become a Silver member of C#Corner.I have joined in c# corner on 7th January.I get into this position with in 4 months.

Since January, I posted 200 posts and 2 articles in c# corner.I have learnt many things from c#corner.I have good friends in c#corner.c# corner Makes differences in my programming life.my confidence level on programming was increased.

Take a look on my profile on c# corner

Vimal Kandasamy Profile

Tuesday, May 5, 2009

MVC Award in C#Corner

C#corner announces MVA & MVC For Jan,Feb,Mar months.I got MVC-Most Valuable Contributor award.MVC award is given to people who contributed in c#corner Forum.

This is my First award through Internet.I have learnt a lot through c#corner.and i just give something back to them and now i got this prestigious award.

Thanks to c#corner team.


To know more, read this news
MVA and MVC for Jan - March 2009 Announced

Monday, May 4, 2009

Execute Another Process or File using c#

Execute another Process or Open a File using its Application is very simple in C#.
There is Separate Name space "System.Diagnostics" is available
There is class named as Process will execute all kind process.

If you want to execute a Exe or open File then a single line can do this
i.e
Process.Start(filepath);

Ex1:
Process.Start("c:\\windows\\notepad.exe");
This statement will open a NotePad Application

Ex2:
Process.Start("c:\\a.doc");


It will Open a.doc File in Word Application.This is applicable to All kind Executable Files.


If you want to give some command line Arguments means use

Process p = new Process();
p.StartInfo.FileName = "c:\\windows\\notepad.exe"; //exe path
p.StartInfo.Arguments = "c:\\a.txt"; //filepath
p.Start();


And also we have more No of options in Process class.
Start Time,End Time,Priority,Memory size,Availability etc.you can start,stop a Process.

If you want to run a process in background
then use following statement.

p.StartInfo.CreateNoWindow = true;


Thank you.