dowloading a file from http

Shurik12
11-23-2006, 07:42 AM
Hi,

Being a novice in the web-programming on the whole and .NET 2.0 (C#)
in particular I'd like to ask the following

I need to automate a process of
1) finding (the most recent ) xml file on a http site
2) porting it to an Oracle database and saving a local copy

Everything seems to be fine with one 'but'. For testnig purposes
I've hardcoded the name of the file


...
XmlTextReader textReader = new XmlTextReader ("http://...TheNameOfTheFile.xml");
textReader.Read();
XmlDocument doc = new XmlDocument();
doc.Load(textReader);
//...
// etc


So the question itself, what the best way to proceed to find the latest avaiable file (see attachment) and pick it up.
Am I on the right way doing something similar too


HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create
("http://....);

HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();
StreamReader streamReader = new StreamReader(webResponse.GetResponseStream(), Encoding.ASCII);

try
{
string outputString;
outputString = streamReader.ReadToEnd();
MessageBox.Show (outputString);
}

catch

{
... ;
}

streamReader.Close();



Does it boil down to parsing outputString ?

Thanks,
Shurik.

PrOpHeT
11-23-2006, 09:24 AM
I can not conceive any other solution other than parsing the returned text and finding the correct link. Unless you control the server it is being downloaded from.

shaul_ahuva
11-23-2006, 01:52 PM
PrOpHeT is correct - you'd need to parse the HTML. But in order to do so, directory browsing/listed needs to be enabled for the site in order to even get the listing page. If the site is hosted by IIS, I *believe* you can also use System.DirectoryServices to get a site's directory listing but I've never attempted it so I don't know the limitations.

Shurik12
11-23-2006, 02:12 PM
Thanks for the responses, guys. By the way the site is hosted on a UNIX machine to my knowledge.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum