Kind of overkill using a browser control to download a file from a web site. You can use the following procedure to do it for you (place in one of your class declarations)
// Add reference for System.Net to the solution
public void DownloadFile(string uri, string fileName)
{
// Create the http request
WebRequest request = WebRequest.Create(uri);
// If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCre
// Get the response.
using (HttpWebResponse response = (HttpWebResponse)request.G
{
// Get the stream containing content returned by the server.
using (Stream dataStream = response.GetResponseStream
{
// Open the stream using a StreamReader for easy access.
using (StreamReader reader = new StreamReader(dataStream))
{
// Create file stream
using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
{
// Convert string to bytes
byte[] info = new UTF8Encoding(true).GetByte
// Write to the file stream
fs.Write(info, 0, info.Length);
// Close the file
fs.Close();
}
// Close the reader
reader.Close();
}
// Close the data stream
dataStream.Close();
}
// Close the response
response.Close();
}
}
// Use it like
DownloadFile("http://somef
---
Regards,
Russell
Main Topics
Browse All Topics





by: Geert_GruwezPosted on 2009-01-29 at 11:05:46ID: 23501137
you probably need to change the zone to c#, you are in the Delphi area ...
Hit the request attention button.