Here this solution for this problem
you know that every microsoft window store the recent open file activity
which is HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs
the C# code is:-
string path = Environment.GetFolderPath(Environment.SpecialFolder.Recent);
var files = Directory.GetFiles(path);
DateTime[] xys = null;
int s = 0;
foreach (string xy in files)
{
s++;
}
xys = new DateTime[s];
s = 0;
foreach (string xy in files)
{
FileInfo fi = new FileInfo(xy);
DateTime dts= fi.LastAccessTime;
xys[s] = dts;
s++;
}
List<DateTime> lst = new List<DateTime>();
foreach(DateTime xyt in xys)
{
lst.Add(xyt);
}
lst.Sort();
lst.Reverse();
string stse="";
string strs = lst.Max(date => date).ToString();
try
{
stse= lst[2].ToString();
}
catch { stse = lst[0].ToString(); };
foreach (string xya in files)
{
FileInfo fi = new FileInfo(xya);
DateTime dts = fi.LastAccessTime;
string stps = dts.ToString();
DateTime stpss = Convert.ToDateTime(stps);
DateTime ne = Convert.ToDateTime(stse);
int result = DateTime.Compare(stpss, ne);
if (result==0)
{
string dst = Path.GetFileName(xya);
textBox1.Text = dst;
break;
}
}