private bool activateWindowIfAlreadyOpen(String fileName)
{
String extension = Path.GetExtension(fileName);
Log.Debug("Extension: [" + extension + "]");
if (extension.Equals(".txt", StringComparison.InvariantCultureIgnoreCase) || String.IsNullOrEmpty(extension))
{
String name = Path.GetFileName(fileName);
String title = name + " - Notepad";
Log.Debug("Finding window " + title);
IntPtr h = User32Interop.FindWindow(null, title);
Log.Debug("handle h = " + h);
if (h != IntPtr.Zero)
{
User32Interop.ShowWindowAsync(h, User32Interop.SW_RESTORE);
activateWindow(h);
return true;
}
Log.Debug("Could not find window");
}
return false;
}