codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  getting the modify date from a file  snowei1 at 03:39 on Saturday, March 13, 2004
 

i have a text file in the web server.
It can be downloaded by a URL "http://servername/file.txt"

I want to be able to get the modify date out from the web server so as to compare it with the text file downloaded on the user desktop. If the file on the user desktop is older, I would like to overwrite the old one on the desktop by downloading the file from the web server.

How can I do that?
Thanks

  Re: getting the modify date from a file  Troy Wolf at 15:52 on Monday, March 15, 2004
 

This is not a complete answer, but to get you started, on the server, in your ASP/VBScript, you can use the filesystem object to retrieve the modified date of the text file.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/FSOoriFileSystemObject.asp?frame=true

Default script security won't allow you to work with the client's local filesystem, but if you have a controlled user base that will allow your script to run, then you can do what you want. This security is of course a good thing -- you don't want any web page being able to modify or even read your local files. The exception to this is the browser cache and cookie files.
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: getting the modify date from a file  snowei1 at 06:19 on Tuesday, March 16, 2004
 

Is there any way to get out a last modified date from a URL?

<Added>

I want to do it in vb only

<Added>

Please provide sample codes to explain how to do it.

  Re: getting the modify date from a file  Troy Wolf at 14:33 on Tuesday, March 16, 2004
 

The HTTP HEADER "Last-Modified" may be exactly what you are looking for. I'm not sure how reliable it is, but I just checked it for a remote HTML and JPG file, and it was correctly returned by my Apache server for both files.

Here is a web page with a cool utility to let you view HTTP Headers for a URL.
http://www.rexswain.com/httpview.html
Input the URL to your file, and see if it isn't what you want.

Here is sample code using ASP/VBScript to perform this task. It relies on the Microsoft XML Core Services component, so you'll need to have that installed on the client for this to work! If you are mass-distributing this client app, this will probably not be a good solution! I believe the .NET library has built-in modules for doing this same kind of thing, but I can't even try to help you with .NET.
set xmlhttp=Server.CreateObject("Msxml2.ServerXMLHTTP")
xmlhttp.open "GET","http://www.mydomain.com/myfolder/myfile.txt"
xmlhttp.send()
xmlresult=xmlhttp.responseText
modified_date = xmlhttp.getResponseHeader("Last-Modified")
response.Write(modified_date)

I'm not a VB programmer, but I think all you have to do to modify the above for VB is remove the "Server." from the first line. I tested the above code with both HTML and image files, so I assume it will work with other file types as well.

In case this helps, here is an ASP/VBScript example for how to get the last modified date of a local file. Again, to turn this into VB, I think all you have to do is remove the "Server." from the first line.
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set file = fso.GetFile(Server.MapPath("/index.html") & "/forum/some_file.txt")
Response.Write(file.DateLastModified)








Troy Wolf: site expert
SnippetEdit Website Editor


  Re: getting the modify date from a file  Troy Wolf at 14:00 on Wednesday, March 17, 2004
 

snowei1, don't forget to follow up here in the forum with your solution. Without feedback, future forum readers are left wondering if the "expert" answer was accurate.

Thanks for using codetoad.com forums! :)
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: getting the modify date from a file  snowei1 at 05:22 on Tuesday, March 23, 2004
 

Never mind I use Inet control and get the date and then trim it to what I want and give it to variable date

<Added>

Ok,now to make it more clear. I use Inet control to get the header of last-modified date. Then I trim of the weekday and the GMT which is suppose to be found when I get the last-modified date in the server.
After that I format it to a date like dd-mm-yyyy hh:nn:ss.

There the date is found.

Thanks to everyone who helped.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: Security - Code verify
•  Job @ EarlySail
•  Job @ EarlySail (perl)
•  IPC problem
•  Re: import contacts of msn/yahoo
•  Cookies and Threads C++
•  right justify a background in a table?
•  Help with Loop (C++/MFC)
•  Help with Loop (C++/MFC)


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007