我有一些我必须解析的旧日志文件 - 显然日期时间保存为:18/12/2012 11:09:39 pm - 我所有解析这些文件的尝试都失败了。我对此完全迷失了 - 任何帮助或指导都会很棒!
CultureInfo cultureInfo = new CultureInfo( "es-MX" , true );
string date = "18/12/2012 11:09:39 p.m.";
DateTime dt = new DateTime( 2012 , 12 , 18 , 11 , 9 , 39 ).AddHours( 12 );
this.richTextBox1.Text += date + Environment.NewLine;
this.richTextBox1.Text += dt.ToString( cultureInfo ) + Environment.NewLine;
this.richTextBox1.Text += dt.ToString() + Environment.NewLine;
foreach ( var item in richTextBox1.Lines )
{
try
{
DateTime d= DateTime.Parse( item );
this.richTextBox1.Text += d.ToString() + Environment.NewLine ;
}
catch ( Exception ee)
{
this.richTextBox1.Text += ee.Message + Environment.NewLine ;
}
}