[Visual C#]Größe von Datei im Internet

05/24/2010 11:20 LordMampf2#1
Ich bin grad dabei mir ein Patcher für einen Metin-Client zu schreiben

Aber wie schaff ich das das Programm von einer Datei auf meinem Webspace die Größe bestimmt,
ohne die Datei herunterzuladen.

Danke im Vorraus!!

grüßle LordMampf2
05/24/2010 11:48 Demon-777#2
Versuchs mal damit:

Code:
public static long GetRemoteFileSize(string fileUrl)
        {
            long size = default(long);
            HttpWebRequest req = default(HttpWebRequest);
            HttpWebResponse res = default(HttpWebResponse);

            try
            {
                req = (HttpWebRequest)HttpWebRequest.Create(fileUrl);
                res = (HttpWebResponse)req.GetResponse();
                size = res.ContentLength;
                req.Abort();

                return size;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: {0}", ex.Message);
                return -1;
            }
        }
05/24/2010 14:30 LordMampf2#3
Vielen Dank klappt super ;)