// When the main window gets told to shut, it calls this function.
// In here things that need to be done before the application stops
// are sorted out.
public void StopApplication()
{
AcquireStop();
profileManager.Exit();
// serialize the lastProfileSet path
if (lastProfileSetPath != null)
{
BinaryFormatter bf = new BinaryFormatter();
String settingsPath = (string)Environs.FileSystem.Paths["settingsPath"];
String filePath = settingsPath + "\\ScanMaster\\profilePath.bin";
FileStream fs = File.Open(filePath, FileMode.Create);
bf.Serialize(fs, lastProfileSetPath);
fs.Close();
}
parameterHelper.Exit();
}