I need to get the latest file from a directory, so using LINQ
I got the file name and gave that file path as a link. When I click the link the file opens. But the problem happens when I click the link for the second time, after closing it. The old content is getting displayed, even though the file has been updated.
I get the file using the following piece of code:
var directory = new DirectoryInfo("C:\\MyDirectory");
var myFile = (from f in directory.GetFiles()
orderby f.LastWriteTime descending
select f).First();`
Then i assign the above file with link to a label using the following code.
label.text="<a href=\"" + "Log\\" + myFile + "\" target = '_NEW' runat='server'>Click</a>"