473,387 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

WinForm app needs to get statistics from a remotely hosted file

JT
Hi,

Is it possible to programmatically read the statistics of a file
hosted on a web server (not controlled by me)? I want to make files
available via RSS based on the suppliers giving me the name and URL of
their file. I don't want to require that they give me the file
length, but that's a required attribute of an RSS item's "enclosure"
element. The file length may change due to updates, so I'd like to be
able to determine the length at the time of the RSS creation.

My presumption is that since the file is available for download, that
anyone would have access to be able to read the file, but the
FileInfo, FileStream, and other classes that I've researched don't
provide access to URLs, that I can see.

Is this just something that's not allowed? Will I need to require the
provider to indicate and maintain the file length?

Thanks,

JT

Aug 11 '07 #1
2 1652
JT,

If the file is a static file, then you should be able to issue an HTTP
HEAD request and get the header information for that file (assuming you have
the url). The content length header will give you the length of the file,
in bytes.

You can use the HttpWebRequest and HttpWebResponse classes to issue this
request and get the content length header in the response.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"JT" <jt@onemain.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
Hi,

Is it possible to programmatically read the statistics of a file
hosted on a web server (not controlled by me)? I want to make files
available via RSS based on the suppliers giving me the name and URL of
their file. I don't want to require that they give me the file
length, but that's a required attribute of an RSS item's "enclosure"
element. The file length may change due to updates, so I'd like to be
able to determine the length at the time of the RSS creation.

My presumption is that since the file is available for download, that
anyone would have access to be able to read the file, but the
FileInfo, FileStream, and other classes that I've researched don't
provide access to URLs, that I can see.

Is this just something that's not allowed? Will I need to require the
provider to indicate and maintain the file length?

Thanks,

JT
Aug 11 '07 #2
JT
Hey Nicholas,

Thanks for the quick response. Here's what I tried:

try
{
System.Net.HttpWebRequest hwrTemp
=
(System.Net.HttpWebRequest)System.Net.WebRequest.C reate(riTemp.Enclosure);
riTemp.FileType =
hwrTemp.Headers.Get("Content-Type");
riTemp.Length =
int.Parse(hwrTemp.Headers.Get("Content-Length"));
}
catch (Exception ex)
{
riTemp.FileType = "application/" +
riTemp.Enclosure.Substring(ExtensionStart);
riTemp.Length = 999999; //
this needs to somehow obtain the file length from the manufacturer's
site
}

ExtensionStart is the file extension portion of the Enclosure
property. Enclosure is the full URL to the file (http://
http://www.TheServerSite.com/Contain...eFileIWant.zip)
What I'm getting is nulls for both headers.

Do I need to provide some sort of credentials for the request, even if
it's anonymous?

Thanks,

JT

Aug 12 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: someone | last post by:
Hi, We are encountering a problem with the DTPicker. This is the situation: We have a DTPicker-control on a VB6 Active-X. The Active-X is used on a .NET winform. the problem: The .Net...
1
by: John | last post by:
Hi We have our web site remotely hosted by a service provider. What we need is to from time to time remotely upload transactions to the site from our office vb.net database app, so the site can...
1
by: Moe | last post by:
I have a winForm control that contains an openFileDialog. I am using this control in a webForm by enbedding it using an <object> tag. I need to access some information about the file on the client....
0
by: terryrey | last post by:
Hi, I've got a winform control that is using Twain and which works fine in a windows application. I am now trying to get this hosted and running in IE6 for our intranet app but am running into...
7
by: John | last post by:
Hi We have our web site remotely hosted by a service provider. We need to, from time to time, remotely upload transactions to the site from our office vb.net app. The question is how can I...
7
by: Dean Slindee | last post by:
I would like to hear some practical comments about how to decide whether a new application becomes a Winform vs a Webform application. Would you say that every app should be, by default, a Winform...
3
by: Larry Hunt | last post by:
I am developing a class which will be used in both a WinForm and ASP.NET 2.0 application. The class needs to know which type of application it is running in. How do you programmatically determine...
0
by: jwinkler2083233 | last post by:
I'm integrating some software from different vendors with a winform hosted in IE, so I don't have control over the source... Here are the symptoms: A Test program with a winform exe calling...
0
by: ibrettferguson | last post by:
I'm trying to figure out how I can grab the logged in user's network Id (easy enough) to pass to a remotely hosted Exchange server, and have that server return the users actual email account. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.