Wednesday, May 12, 2004

Working with office solutions

 

Considering the way that Microsoft office uses temporary files which makes it impossible for me to know exactly when the original (not the temporary file) was updated using a FileSystemWatcher, I decided to change the design in such a way that I keep track of the when the process with which I opened the office application on exits.

 

Using

 

Process process = new Process();

 

      process.EnableRaisingEvents = true;

      process.Exited += new EventHandler(process_Exited);

      process.StartInfo = pInfo;

 

// start process

process.Start();

 

Since the user can open more office document of this sort, I also kept this processes in a list

 

WatchProcess.Add(process);

 

So that on closing of my main form I can know which processes have not been exited. Display a warning to the user, and force an exit

 

private void FrmMainEMR_Closing(object sender, System.ComponentModel.CancelEventArgs e)

      {

            if (WatchProcess.Count > 0)

            {

                  if (new FrmConfirmation().ShowDialog(this) == DialogResult.Yes)

                        CloseApplication();

                  else

                        e.Cancel = true;

            }

            else

                  CloseApplication();

      }

}

 

 

This is how I was able to get thru this. Now I can sleep tonight as this has kept me up for a couple of nights. Thanx

 

 

Onawole, Clement Oladapo

Lead Software Developer
Splashers Technologies
Suite B15 Festac Plaza
24 Road Festac
Tel: 234-802-316-6353
www25.brinksters.com/murpheux