Most recent file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lee

    #1

    Most recent file

    I have an application where I need to find the most recent file placed in a
    folder. For example, my users periodically place an image file with the
    format "ImageXXXX. jpg" (where XXXX is some arbitrary number) and I need to
    get the latest file in the folder. Does anyone have a .NET solution to this
    problem. Any help would be greatly appreciated
    Thanks,
    Lee

  • Miro

    #2
    Re: Most recent file

    Would you not be able to use FileSystemWatch er?

    It would get hit the instant a file would be created in your folder - or
    subfolder.

    Miro
    -New to VB.net so you may want some other opinions.



    "Lee" <lee.hudson_2@p hilips.comwrote in message
    news:8C23853B-08F6-4E1A-AB94-85E3E719B6DB@mi crosoft.com...
    >I have an application where I need to find the most recent file placed in a
    folder. For example, my users periodically place an image file with the
    format "ImageXXXX. jpg" (where XXXX is some arbitrary number) and I need to
    get the latest file in the folder. Does anyone have a .NET solution to
    this
    problem. Any help would be greatly appreciated
    Thanks,
    Lee
    >

    Comment

    • Lee

      #3
      Re: Most recent file

      Not really. I don't think I explained the problem very well. I have a list
      of files with a *.jpg extension and I need to find the most recent file in
      the list which may not be the most recent file in the folder because other
      people may have put files in there without the *.jpg extension.


      "Miro" wrote:
      Would you not be able to use FileSystemWatch er?
      >
      It would get hit the instant a file would be created in your folder - or
      subfolder.
      >
      Miro
      -New to VB.net so you may want some other opinions.
      >
      >
      >
      "Lee" <lee.hudson_2@p hilips.comwrote in message
      news:8C23853B-08F6-4E1A-AB94-85E3E719B6DB@mi crosoft.com...
      I have an application where I need to find the most recent file placed in a
      folder. For example, my users periodically place an image file with the
      format "ImageXXXX. jpg" (where XXXX is some arbitrary number) and I need to
      get the latest file in the folder. Does anyone have a .NET solution to
      this
      problem. Any help would be greatly appreciated
      Thanks,
      Lee
      >
      >
      >

      Comment

      • John Timney \(MVP\)

        #4
        Re: Most recent file

        You could still tie into filesystemwatch er. Just iterate the files with
        that extension you seek when watcher indicates a file has changed, and look
        at their properties of all files using the FileInfo class.

        something like:FileInfo fFile = new FileInfo(theite ratedfilename);
        DateTime fred = fFile.CreationT ime.ToString()

        Subtract the created date from datetime.now using timespan classes subtract
        method to give you span.Seconds, and you have how long ago the file was
        created.

        If that figure is less than the last files figure then the current file in
        the iteration is the most recent. Just repeat until all the files are
        checked.

        Regards

        John Timney (MVP)


        "Lee" <lee.hudson_2@p hilips.comwrote in message
        news:3610C813-CB9F-45E7-945F-4F5A672B91C9@mi crosoft.com...
        Not really. I don't think I explained the problem very well. I have a
        list
        of files with a *.jpg extension and I need to find the most recent file in
        the list which may not be the most recent file in the folder because other
        people may have put files in there without the *.jpg extension.
        >
        >
        "Miro" wrote:
        >
        >Would you not be able to use FileSystemWatch er?
        >>
        >It would get hit the instant a file would be created in your folder - or
        >subfolder.
        >>
        >Miro
        >-New to VB.net so you may want some other opinions.
        >>
        >>
        >>
        >"Lee" <lee.hudson_2@p hilips.comwrote in message
        >news:8C23853 B-08F6-4E1A-AB94-85E3E719B6DB@mi crosoft.com...
        >I have an application where I need to find the most recent file placed
        >in a
        folder. For example, my users periodically place an image file with
        the
        format "ImageXXXX. jpg" (where XXXX is some arbitrary number) and I need
        to
        get the latest file in the folder. Does anyone have a .NET solution to
        this
        problem. Any help would be greatly appreciated
        Thanks,
        Lee
        >
        >>
        >>
        >>

        Comment

        • Lee

          #5
          Re: Most recent file

          Thanks, John. I'll work with that.
          Regards,
          Lee


          "John Timney (MVP)" wrote:
          You could still tie into filesystemwatch er. Just iterate the files with
          that extension you seek when watcher indicates a file has changed, and look
          at their properties of all files using the FileInfo class.
          >
          something like:FileInfo fFile = new FileInfo(theite ratedfilename);
          DateTime fred = fFile.CreationT ime.ToString()
          >
          Subtract the created date from datetime.now using timespan classes subtract
          method to give you span.Seconds, and you have how long ago the file was
          created.
          >
          If that figure is less than the last files figure then the current file in
          the iteration is the most recent. Just repeat until all the files are
          checked.
          >
          Regards
          >
          John Timney (MVP)
          >
          >
          "Lee" <lee.hudson_2@p hilips.comwrote in message
          news:3610C813-CB9F-45E7-945F-4F5A672B91C9@mi crosoft.com...
          Not really. I don't think I explained the problem very well. I have a
          list
          of files with a *.jpg extension and I need to find the most recent file in
          the list which may not be the most recent file in the folder because other
          people may have put files in there without the *.jpg extension.


          "Miro" wrote:
          Would you not be able to use FileSystemWatch er?
          >
          It would get hit the instant a file would be created in your folder - or
          subfolder.
          >
          Miro
          -New to VB.net so you may want some other opinions.
          >
          >
          >
          "Lee" <lee.hudson_2@p hilips.comwrote in message
          news:8C23853B-08F6-4E1A-AB94-85E3E719B6DB@mi crosoft.com...
          I have an application where I need to find the most recent file placed
          in a
          folder. For example, my users periodically place an image file with
          the
          format "ImageXXXX. jpg" (where XXXX is some arbitrary number) and I need
          to
          get the latest file in the folder. Does anyone have a .NET solution to
          this
          problem. Any help would be greatly appreciated
          Thanks,
          Lee

          >
          >
          >
          >
          >
          >

          Comment

          Working...