private static void RecordLastAppForProject()
{
if (s_cache == null || s_cache.IsDisposed)
return; // too late
if (!s_cache.ProjectId.IsLocal)
return; // not point in recording for a remote project, can't double-click that here.
if (s_flexApp != null && s_teApp != null)
return; // this isn't the last one to shut down, not time to record.
var settingsFolder = Path.Combine(Cache.ProjectId.ProjectFolder, FdoFileHelper.ksConfigurationSettingsDir);
var teMarkerPath = Path.Combine(settingsFolder, ksTeOpenMarkerFileName);
try
{
Directory.CreateDirectory(settingsFolder); // make sure
if (s_teApp == null)
{
// flex is shutting down last, get rid of the marker.
File.Delete(teMarkerPath);
}
else if (!File.Exists(teMarkerPath))
{
// TE is shutting down last, create the marker file if it doesn't already exist.
using (var writer = new StreamWriter(teMarkerPath))
{
writer.WriteLine("This file is just present to indicate that TE had this project open last");
writer.Close();
}
}
}
catch (IOException)
{
// No great harm done if we can't write this marker
}
catch (SecurityException)
{
// Likewise
}
catch (UnauthorizedAccessException)
{
// and another
}
}
#endregion