File properties of a file on a server

S

Shishir

Hi All,

I am looking for some pointers about how to get File properties
of some file lying on some HTTP or FTP server. Basically I want to
check the date and time of modification of that file.
As far as I know, if I attach a FileInfo object with a file on a
filesystem, I will be able to get the time/date it was last modified.
But problem is FileInfo can't be attached to a HTTP/FTP resource.
Please give me some information regarding this.

TIA,
Shishir.
 
C

Cor Ligthert

Shishir,

This you can use for HTTP (when you want the file name, just take the full
url to it.

\\\
//using System.Net;
HttpWebRequest wbRq =
(HttpWebRequest)WebRequest.Create("http://www.microsoft.com");
wbRq.Timeout = 2000;
try
{
HttpWebResponse wbRs = (HttpWebResponse)wbRq.GetResponse();
WebHeaderCollection wbHCol = wbRs.Headers;
for (int i = 0; i < wbHCol.Count; i++)
{
string header = wbHCol.GetKey(i);
string[] values = wbHCol.GetValues(header);
if (values.Length > 0)
{
Console.Write(header);
Console.Write(" ");
Console.Write(values[0]);
Console.Write((char)13);
}
wbRs.Close();
}
}
catch
{
Console.Write("could not get something");
}
///

I hope this helps a little bit?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top