public static ProcessInfo GetProcessInfo() { var process = Process.GetCurrentProcess(); var processInfo = new ProcessInfo { TotalMemoryUsed = $"{SystemInfoUtils.ByteToGB((ulong)process.WorkingSet64)} GB / {SystemInfoUtils.ByteToGB((ulong)process.PeakWorkingSet64)} GB", RunningTime = $"{DateTime.Now - process.StartTime}", CommandLine = Environment.CommandLine, ExecutablePath = process.MainModule.FileName, WorkingDirectory = Environment.CurrentDirectory }; return(processInfo); }
public string GenerateReport(Exception exception, string productName) { var builder = new StringBuilder(); builder.AppendLine("Application crashed report".ToUpper()); builder.AppendLine(); builder.AppendLine($"Product: {productName}"); builder.AppendLine($"Report date: {DateTime.Now}"); builder.AppendLine($"-----------------------------------------------"); builder.AppendLine($"System Information"); builder.AppendLine(SystemInfoUtils.GetSystemInfo().ToString()); builder.AppendLine($"-----------------------------------------------"); builder.AppendLine($"Process Information"); builder.AppendLine(ProcessInfoUtils.GetProcessInfo().ToString()); builder.AppendLine($"-----------------------------------------------"); builder.AppendLine($"Exception"); builder.Append(exception); return(builder.ToString()); }