public bool Download()
{
bool success = false;
try
{
if (!Directory.Exists(Application.StartupPath + @"\Update"))
{
Directory.CreateDirectory(Application.StartupPath + @"\Update");
}
string url = "http://www.andwho.com/AndwhoUpdate/DeskHelper/DeskHelper.xml";
Uri uri = new Uri(url);
HttpWebRequest mRequest = (HttpWebRequest)WebRequest.Create(uri);
mRequest.Method = "GET";
mRequest.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse mResponse = (HttpWebResponse)mRequest.GetResponse();
Stream sIn = mResponse.GetResponseStream();
FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);
long length = mResponse.ContentLength;
long i = 0;
while (i < length)
{
byte[] buffer = new byte[length];
int read = sIn.Read(buffer, 0, buffer.Length);
i += read;
string strTemp = System.Text.Encoding.UTF8.GetString(buffer, 0, read);
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(strTemp);
fs.Write(bytes, 0, bytes.Length);
}
sIn.Close();
mResponse.Close();
fs.Close();
success = true;
}
catch
{
}
return success;
}