Exemple #1
0
		/// <summary>
		/// uninstall the service
		/// </summary>
		private static void Uninstall ()
			{
			IDictionary savedState = null;

			string savedStateFileName = Path.ChangeExtension (typeof (FolderWatcherService).Module.FullyQualifiedName, ".install");
			if (File.Exists (savedStateFileName))
				{
				using (FileStream fileStream = new FileStream (savedStateFileName, FileMode.Open, FileAccess.Read))
					{
					savedState = (IDictionary) new BinaryFormatter ().Deserialize (fileStream);
					}

				File.Delete (savedStateFileName);
				}

			using (WatcherServiceInstaller installer = new WatcherServiceInstaller ())
				{
				installer.Uninstall (savedState);
				}
			}
Exemple #2
0
		/// <summary>
		/// install the service
		/// </summary>
		private static void Install ()
			{
			IDictionary savedState = new Hashtable ();
			using (WatcherServiceInstaller installer = new WatcherServiceInstaller ())
				{
				installer.Install (savedState);

				if (savedState.Keys.Count != 0)
					{
					string savedStateFileName = Path.ChangeExtension (typeof (FolderWatcherService).Module.FullyQualifiedName, ".install");
					Console.WriteLine ("Writing " + savedStateFileName + ".");
					using (FileStream fileStream = new FileStream (savedStateFileName, FileMode.Create, FileAccess.Write))
						{
						new BinaryFormatter ().Serialize (fileStream, savedState);
						}
					}
				}
			}