public void UploadToVBAddict(string filePath, string playerID, MessageQueue message) { try { FileInfo toUpload = new FileInfo(filePath); byte[] data = File.ReadAllBytes(filePath); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.vbaddict.net/xxx.php"); request.Proxy.Credentials = CredentialCache.DefaultCredentials; request.Method = "PUT"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; request.Headers.Clear(); request.Referer = toUpload.Name; request.UserAgent = "WOTStatistics 2.1.0.0"; request.ServicePoint.Expect100Continue = false; using (Stream stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = request.GetResponse(); Stream outStream = response.GetResponseStream(); StreamReader reader = new StreamReader(outStream); // Read the content. string responseFromServer = reader.ReadToEnd(); if (responseFromServer.Contains("SUCCESS")) { using (PlayerListing pl = new PlayerListing(new MessageQueue())) { if (pl.GetPlayer(playerID).OnlineURL == "#") { pl.SetPlayerOnlineURL(playerID, responseFromServer.Substring(responseFromServer.IndexOf("Link: ") + 6).Replace("SUCCESS", "")); try { pl.Save(); } catch { } } } } response.Close(); } catch (Exception ex) { message.Add(ex.Message); } }
void _dossierWatcher_Changed(object sender, FileSystemEventArgs e) { if (GetPlayerName == WOTHelper.PlayerIdFromDatFile(e.Name)) { if (string.Compare(_dossierFilePath, e.FullPath, true) != 0) { using (PlayerListing player = new PlayerListing(_messages)) { player.SetPlayerWatchFile(GetPlayerID, e.FullPath); player.Save(); } _dossierFilePath = e.FullPath; } ProcessDossierFile(); } }