//我这里是获得图片文件
public struct ImagePath
{
public string Path1 { get; set; } //最新的
public string Path2 { get; set; } //更早的
}
public ImagePath GetAllFileInfo(string FileImagePath)
{
ImagePath Getpath = new ImagePath();
try
{
DirectoryInfo files = new DirectoryInfo(FileImagePath);
bool hasValue = false;
DateTime m_LastActionTime = new DateTime(1970, 1, 1); //设置默认时间
System.IO.FileInfo[] allFile = files.GetFiles();
foreach (FileInfo file in allFile)
{
if (hasValue)
{
if (file.CreationTime > m_LastActionTime)
{
if (file.Name.Contains(".bmp"))
{
m_LastActionTime = file.CreationTime;
Getpath.Path1 = file.FullName;
}
}
}
else
{
if (file.Name.Contains(".bmp"))
{
m_LastActionTime = file.CreationTime; //运行第一次 把第一个文件创建时间获得
Getpath.Path2 = file.FullName;
hasValue = true;
}
}
}
return Getpath;
}
catch (Exception ex)
{
return Getpath;
}
}