Results 1 to 4 of 4

Thread: Finding LastModifiedDate of file using URL

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2009
    Posts
    258

    Question Finding LastModifiedDate of file using URL

    There's a website that maintains links to PDF files, and I want to check to see if the file has changed since the last time I downloaded it. I've got everything working except retrieving the LastModifiedDate of the file. The code I am using is as follows:

    Code:
    Try
        Dim req As HttpWebRequest = (WebRequest.Create(url))
        Dim resp As HttpWebResponse = (req.GetResponse())
        Dim dt As String = resp.LastModified.ToString()
        lblLnk1Mthd2.Text = dt
    Catch ex As Exception
        lblLnk1Mthd2.Text = "Error"
    End Try
    I am using VS 2010 on Windows 7, and have verified that the url I pass in does exist and is a valid link to a PDF file. What happens when I run this code is that the current date/time is returned, instead of the last modified date of the PDF file. Does anybody have any suggestions on how I can get the LastModifiedDate of a PDF on the net? Thanks in advance.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Finding LastModifiedDate of file using URL

    You're doing it. This code works perfectly for files of all kinds on the test sites I used. So you're getting what the site gives you.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2009
    Posts
    258

    Re: Finding LastModifiedDate of file using URL

    If I'm doing it right, why is it returning the current date/time every time I run the thing? The specific file I'm looking at is:

    http://cignaforhcp.cigna.com/public/..._treatment.pdf

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Finding LastModifiedDate of file using URL

    Because, as I said, that is what the site is giving you. It may that the file is essentially created for you at the time of access, or that the last modified date is hidden at the server, or any number of other reasons. The point is that there is nothing you can do about it. It is controlled entirely by the server and is therefore out of your hands.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width