需要帮助转换shell . folder . getdetailsofstring到DateTime

本文关键字:getdetailsofstring DateTime folder shell 帮助 转换 | 更新日期: 2023-09-27 18:01:48

我不知道如何将按下面返回的记录时间转换为日期时间。我的代码是:

Shell shell = new Shell();
Folder folder = shell.NameSpace("D:'Recorded Tv");  
string recordingTime = folder.GetDetailsOf(WTVfile, 260);  
string[] formats = { @"dd'/MM'/yyyy", @"d'/MM'/yyyy h:mm tt", @"d'/MM'/yyyy" };
DateTime recordingDateTime = DateTime.Now;
DateTime.TryParseExact(recordingTime, formats, CultureInfo.InvariantCulture, DateTimeStyles.None, out recordingDateTime);

问题是,在recordingTime所有密集目的的字符串值看起来很好,肉眼,在上述情况下,"07/03/2014 7:30 PM",但它显然没有被返回,因为我期待在上面的代码之后,recordingDateTime是"01/01/1000 12:00:00 AM"

如果我将recordingTime中的值复制到剪贴板中,并将其粘贴到代码窗格中,并将其包裹在兔子耳朵中,然后保存,它会给我一个unicode警告。

我的问题是如何解析recordingTime字符串是在同一文化??如预期的TryParseExact方法调用?

我希望我说得更清楚:)

感谢马特

需要帮助转换shell . folder . getdetailsofstring到DateTime

通过这里提供的regex表达式剥离不可打印字符为我解决了这个问题:

val = Regex.Replace(val, @"[^'u0000-'u007F]", string.Empty);
相关文章:
  • 没有找到相关文章