Results 1 to 2 of 2

Thread: Need help finding newest file in a computer folder

  1. #1
    Join Date
    Dec 2004
    Posts
    2,040
    Rep Power
    22

    Default Need help finding newest file in a computer folder

    I need to be able to find the latest file added in a folder on a computer from a website. I was looking into DirectoryInfo class, I guess creationtime but was told that i'll have to change some security settings in IE to allow the site to read the directory for the file which we don't want to do. Is there a way for me to do this (locate the newest file in the folder) without troubling security settings?
    This posting is provided "AS IS" with no warranties, and confers no rights.
    You assume all risk for your use. © 2006 Cloud Solutions. All rights reserved.

  2. #2
    Join Date
    Dec 2004
    Posts
    2,040
    Rep Power
    22

    Default

    Found a couple ways to do it, here's the one i'll be using
    DirectoryInfo directory = new DirectoryInfo(@"D:\testing\");

    FileInfo myFile = (from f in directory.GetFiles() orderby f.LastWriteTime descending select f).First();
    This posting is provided "AS IS" with no warranties, and confers no rights.
    You assume all risk for your use. © 2006 Cloud Solutions. All rights reserved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •