DateTime.ParseExact not working

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Im pulling timestamps on files from an FTP server, and attempting to convert them into a DateTime variable. However, because of a leading zero on the hour, the standard "Parse" function throws a Gregorian Calendar exception. Ive tried the following
code, and keep getting formatting errors. Ive tried the invariant culture, allowing whitespace, etc... Im hoping it is something obvious because I feel like it should be.

<div style="color:Black;background-color:White; <pre>
CultureInfo provider = <span style="color:Blue; new CultureInfo(<span style="color:#A31515; "en-US");
<span style="color:Blue; string format = <span style="color:#A31515; "MMM d hh:mm";
<span style="color:Blue; string dtpre = <span style="color:#A31515; "Jan 4 17:12";
<span style="color:Green; //string dtpre = "Jan 4 03:24";
_fileDateTime = DateTime.ParseExact(dtpre, format, provider);
[/code]
<br/>
<hr class="sig If It Was So, It Might Be, And If It Were So, It Would Be, But as It Isnt, It Aint. Thats logic.

View the full article
 
Back
Top