1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
Random rd=new Random();
int theChiffre=rd.Next(1,99999999);
WebRequest request = WebRequest.Create("http://www.monsite.fr//retourIdentifiantXml.php?" + theChiffre.ToString());
// If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCredentials;
// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//// Display the status.
//Console.WriteLine(response.StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
//// Display the content.
//Console.WriteLine(responseFromServer);
MessageBox.Show(responseFromServer);
// Cleanup the streams and the response.
reader.Close();
dataStream.Close();
response.Close();
client.DownloadFile(cheminSurServeur + responseFromServer + fichier, cheminsurpclocal + responseFromServer+fichier); |