Click here to Skip to main content
15,905,682 members
Home / Discussions / C#
   

C#

 
GeneralRe: Print Multiple instances of the same form Pin
ferronrsmith19-Jan-09 9:10
ferronrsmith19-Jan-09 9:10 
GeneralRe: Print Multiple instances of the same form Pin
#realJSOP19-Jan-09 9:16
professional#realJSOP19-Jan-09 9:16 
QuestionProblem with com creation in C# Pin
Arish rivlin19-Jan-09 3:00
Arish rivlin19-Jan-09 3:00 
AnswerRe: Problem with com creation in C# Pin
Not Active19-Jan-09 3:20
mentorNot Active19-Jan-09 3:20 
QuestionHow to get the list of Href Links From HTML Pin
wasimsharp19-Jan-09 2:39
wasimsharp19-Jan-09 2:39 
AnswerRe: How to get the list of Href Links From HTML Pin
Paddy Boyd19-Jan-09 2:42
Paddy Boyd19-Jan-09 2:42 
AnswerRe: How to get the list of Href Links From HTML Pin
J a a n s19-Jan-09 3:52
professionalJ a a n s19-Jan-09 3:52 
QuestionCultureInfo and DateTime settings Pin
Rick van Woudenberg19-Jan-09 2:33
Rick van Woudenberg19-Jan-09 2:33 
Gents,

I have the following problem that drives me insane. I've written a service that runs in the background. However, I can't get the DateTime format right. I must have tried everything to get it right, but to no avail. When the service starts or stops, it will tell me by writing to a log file. The output of the log file looks like this :

1/19/2009 1:48:40 PM Manager: Service Stopped<br />
1/19/2009 1:48:43 PM Manager: Service Started<br />
1/19/2009 2:17:05 PM Manager: Service Stopped<br />
1/19/2009 2:17:29 PM Manager: Service Started<br />
1/19/2009 2:18:02 PM Manager: Service Stopped<br />
1/19/2009 2:20:27 PM Manager: Service Started


Now .. When it writes to the logfile, it uses the above format for DateTime.Now , while I want to use "dd-mm-yyyy HH:mm:ss"
I set the regional setting in Control Panel as well as the Date and Time format. It shows up perfect in my system clock. It still spits out the above to the logfile. Then I tried the following in my code, so set it programmatically :

// The main entry point for the process
static void Main()
{
    //Set the culture
    CultureInfo newCulture = new CultureInfo("en-US", false);
    newCulture.DateTimeFormat.FullDateTimePattern = "dd-mm-yyyy HH:mm:ss";
    System.Threading.Thread.CurrentThread.CurrentCulture = newCulture;

    System.ServiceProcess.ServiceBase[] ServicesToRun;
    // More than one user Service may run within the same process. To add
    // another service to this process, change the following line to
    // create a second service object. For example,
    //
    // ServicesToRun = New System.ServiceProcess.ServiceBase[] {new WinService1(), new ySecondUserService()};
    //
    ServicesToRun = new System.ServiceProcess.ServiceBase[] { new RealTime() };
    System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}


That didn't fix it .. still the same output.
When I put a MessageBox in between somewhere to let me show DateTime.Now.ToString(), it also comes back with 1/19/2009 2:20:27 PM. Some of the methods in the service report an invalid <code>DateTime</code> conversion when I try the following code :

DateTime time = Convert.ToDateTime("19-01-2009 13:12:56");


It drives me insane. Can please someone point me in the right direction ?

Kind regards,
AnswerRe: CultureInfo and DateTime settings Pin
Arish rivlin19-Jan-09 3:05
Arish rivlin19-Jan-09 3:05 
GeneralRe: CultureInfo and DateTime settings Pin
Rick van Woudenberg19-Jan-09 4:43
Rick van Woudenberg19-Jan-09 4:43 
GeneralRe: CultureInfo and DateTime settings Pin
Arish rivlin19-Jan-09 5:51
Arish rivlin19-Jan-09 5:51 
GeneralRe: CultureInfo and DateTime settings Pin
Vikram A Punathambekar19-Jan-09 6:31
Vikram A Punathambekar19-Jan-09 6:31 
GeneralRe: CultureInfo and DateTime settings Pin
Rick van Woudenberg19-Jan-09 11:31
Rick van Woudenberg19-Jan-09 11:31 
GeneralRe: CultureInfo and DateTime settings Pin
Vikram A Punathambekar20-Jan-09 4:31
Vikram A Punathambekar20-Jan-09 4:31 
QuestionVirtual com port Pin
queries36519-Jan-09 2:22
queries36519-Jan-09 2:22 
AnswerRe: Virtual com port Pin
Bharat Jain19-Jan-09 3:44
Bharat Jain19-Jan-09 3:44 
GeneralRe: Virtual com port Pin
queries36519-Jan-09 4:04
queries36519-Jan-09 4:04 
GeneralRe: Virtual com port Pin
Dan Neely19-Jan-09 4:59
Dan Neely19-Jan-09 4:59 
GeneralRe: Virtual com port Pin
queries36519-Jan-09 19:00
queries36519-Jan-09 19:00 
GeneralRe: Virtual com port Pin
Dan Neely20-Jan-09 4:47
Dan Neely20-Jan-09 4:47 
GeneralRe: Virtual com port Pin
queries36520-Jan-09 19:21
queries36520-Jan-09 19:21 
AnswerRe: Virtual com port [modified] Pin
Luc Pattyn19-Jan-09 4:37
sitebuilderLuc Pattyn19-Jan-09 4:37 
GeneralRe: Virtual com port Pin
queries36519-Jan-09 19:03
queries36519-Jan-09 19:03 
AnswerRe: Virtual com port [modified] Pin
Luc Pattyn20-Jan-09 1:32
sitebuilderLuc Pattyn20-Jan-09 1:32 
GeneralRe: Virtual com port Pin
queries36520-Jan-09 4:08
queries36520-Jan-09 4:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.