Hi I’m trying to develop a utility to manage large sets of backup’s:
I have my backups structured like:
D:\SQLBACKUP\NOFAULT2010\Datatbase\LOG\NOFAULT2010_Datatbase_LOG_20110906_182000.trn
D:\SQLBACKUP\NOFAULT2010\Datatbase\LOG\NOFAULT2010_Database_LOG_20110906_183000.trn
I can get rid of the static parts easily enough
Replace(@"D:\SQLBACKUP\NOFAULT2010\Datatbase\LOG\NOFAULT2010_Datatbase_LOG_", "").Replace(".trn", "");
How can I consistently parse this part 20110906_182000 … I’m open to any other suggestions. Thanks My brain is on vacation today something terrible.
You can parse out hour, minutes, seconds, etc. with Substring() and then use
new DateTime()to create an instance of the date class.An alternative is to use
DateTime.TryParseExact()(http://msdn.microsoft.com/en-us/library/ms131044.aspx)