public bool PostCrashLog(string email, string comments) { string filePath = UtilAll.GetLogFileOld(); if (!File.Exists(filePath)) { this.ResultMessage = Catalog.GetString("Could not send file.\nIt does not exist."); return(false); } if (comments != null && comments != "") { Util.InsertTextBeginningOfFile( "----------\nUser comments:\n" + comments + "\n----------\n", filePath); } // Create a request using a URL that can receive a post. WebRequest request = WebRequest.Create(serverUrl + "/backtrace/" + UtilAll.ReadVersionFromBuildInfo() + "-" + email); // Set the Method property of the request to POST. request.Method = "POST"; // Create POST data and convert it to a byte array. byte[] byteArray = readFile(filePath); // Set the ContentType property of the WebRequest. request.ContentType = "application/x-www-form-urlencoded"; // Set the ContentLength property of the WebRequest. request.ContentLength = byteArray.Length; // Get the request stream. Stream dataStream; try { dataStream = request.GetRequestStream(); } catch { LogB.Warning("Error sending datastream"); this.ResultMessage = Catalog.GetString("Could not send file.") + "\n" + string.Format(Catalog.GetString("You are not connected to the Internet\nor {0} server is down."), serverUrl); return(false); } // Write the data to the request stream. dataStream.Write(byteArray, 0, byteArray.Length); // Close the Stream object. dataStream.Close(); // Get the response. WebResponse response; try { response = request.GetResponse(); } catch { LogB.Warning("Error getting response"); this.ResultMessage = Catalog.GetString("Could not send file.") + "\n" + string.Format(Catalog.GetString("You are not connected to the Internet\nor {0} server is down."), serverUrl); return(false); } // Display the status. LogB.Information(((HttpWebResponse)response).StatusDescription); // Get the stream containing content returned by the server. 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. LogB.Information(responseFromServer); // Clean up the streams. reader.Close(); dataStream.Close(); response.Close(); JsonValue result = JsonValue.Parse(responseFromServer); string crash_id = result["crash_id"]; LogB.Information("crash_id: ", crash_id); this.ResultMessage = Catalog.GetString("Log sent. Thank you."); return(true); }