Return DateTime info of file on webserver

Harrison

Member
Joined
Oct 29, 2009
Messages
9
Programming Experience
3-5
Hi,

I'm trying to get the datetime info of a file located on a server

e.g "http://vbdotnetforums.com/Folder/File.ZIP", does anyone know how to do this?

Many thanks.
 
Last edited:
Hi i hope this helps, if its what your looking for, i didnt write this, just found it Searching the INet:

HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("http://www.teslaeurope.com/
default.htm");

// If required by the server, set the credentials.
//request.Credentials =
CredentialCache.DefaultCredentials;
//request.IfModifiedSince = DateTime.Parse("01-01-1990");

try
{
using (WebResponse response = request.GetResponse())
{
string lastModified = response.Headers["Last-
Modified"].ToString();
}
}
catch (WebException wex)


enjoy :)
 
VB.NET:
Dim req As Net.WebRequest = Net.WebRequest.Create("http://vbdotnetforums.com/Folder/File.ZIP")
req.Method = Net.WebRequestMethods.Http.Head
Dim res As Net.HttpWebResponse = CType(req.GetResponse, Net.HttpWebResponse)
Dim lastModified As Date = res.LastModified
res.Close()
 
Back
Top