Skip to content

Commit

Permalink
Fixing possible NRE
Browse files Browse the repository at this point in the history
  • Loading branch information
synhershko committed Jul 11, 2012
1 parent 65a040a commit bf09759
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/NAppUpdate.Updater/AppStart.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;
Expand Down Expand Up @@ -39,8 +38,11 @@ private static void Main()
logFile = System.Reflection.Assembly.GetEntryAssembly().Location;
logFile = Path.Combine(Path.GetDirectoryName(logFile), @"logs\NauUpdate.log");

_console.WriteLine("Logging to {0}", logFile);
_console.WriteLine();
if (_args.ShowConsole)
{
_console.WriteLine("Logging to {0}", logFile);
_console.WriteLine();
}
}

try
Expand Down Expand Up @@ -186,26 +188,25 @@ private static void Main()

private static void SelfCleanUp(string tempFolder)
{
// Delete the updater EXE and the temp folder
Log("Removing updater and temp folder... {0}", tempFolder);
try
{
// Delete the updater EXE and the temp folder
Log("Removing updater and temp folder... {0}", tempFolder);
try
{
var Info = new ProcessStartInfo
{
Arguments = string.Format(@"/C ping 1.1.1.1 -n 1 -w 3000 > Nul & echo Y|del ""{0}\*.*"" & rmdir ""{0}""", tempFolder),
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
FileName = "cmd.exe"
};

Process.Start(Info);
}
catch { /* ignore exceptions thrown while trying to clean up */ }
var info = new ProcessStartInfo
{
Arguments =
string.Format(@"/C ping 1.1.1.1 -n 1 -w 3000 > Nul & echo Y|del ""{0}\*.*"" & rmdir ""{0}""",
tempFolder),
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
FileName = "cmd.exe"
};

Process.Start(info);
}
catch
{
/* ignore exceptions thrown while trying to clean up */
}
}

Expand Down Expand Up @@ -239,6 +240,8 @@ private static void Log(Exception ex)
_console.WriteLine();
_console.WriteLine("The updater will close when you close this window.");
}

Application.DoEvents();
}
}
}

0 comments on commit bf09759

Please sign in to comment.