public void StartMonitoring(string filePath, OnChangedCallback onChangedCallback, out object state, out DateTimeOffset lastWriteTime, out long fileSize)
        {
            if (String.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException("filePath");
            }

            callback = onChangedCallback;

            string parentDir;

            if (File.Exists(filePath))
            {
                var fi = new FileInfo(filePath);
                lastWriteTime = DateTimeOffset.FromFileTime(fi.LastWriteTimeUtc.Ticks);
                fileSize      = fi.Length;
                parentDir     = Path.GetDirectoryName(filePath);
            }
            else if (Directory.Exists(filePath))
            {
                var di = new DirectoryInfo(filePath);
                lastWriteTime = DateTimeOffset.FromFileTime(di.LastWriteTimeUtc.Ticks);
                fileSize      = -1L;
                parentDir     = filePath;
            }
            else
            {
                lastWriteTime = DateTimeOffset.MaxValue;
                fileSize      = -1L;

                if (filePath.LastIndexOf(Path.DirectorySeparatorChar) != -1)
                {
                    parentDir = Path.GetDirectoryName(filePath);
                }
                else
                {
                    parentDir = filePath;
                }
            }

            FileChangeNotificationSystemEntry entry;

            lock (watchers_lock) {
                Dictionary <string, FileChangeNotificationSystemEntry> watchers = Watchers;

                if (!watchers.TryGetValue(parentDir, out entry))
                {
                    entry = new FileChangeNotificationSystemEntry(parentDir, this);
                    watchers.Add(parentDir, entry);
                }

                entry.Add(filePath);
                entry.Start();
            }

            state = entry;
        }
		public void StartMonitoring (string filePath, OnChangedCallback onChangedCallback, out object state, out DateTimeOffset lastWriteTime, out long fileSize)
		{
			if (String.IsNullOrEmpty (filePath))
				throw new ArgumentNullException ("filePath");
			
			callback = onChangedCallback;

			string parentDir;
			if (File.Exists (filePath)) {
				var fi = new FileInfo (filePath);
				lastWriteTime = DateTimeOffset.FromFileTime (fi.LastWriteTimeUtc.Ticks);
				fileSize = fi.Length;
				parentDir = Path.GetDirectoryName (filePath);
			} else if (Directory.Exists (filePath)) {
				var di = new DirectoryInfo (filePath);
				lastWriteTime = DateTimeOffset.FromFileTime (di.LastWriteTimeUtc.Ticks);
				fileSize = -1L;
				parentDir = filePath;
			} else {
				lastWriteTime = DateTimeOffset.MaxValue;
				fileSize = -1L;

				if (filePath.LastIndexOf (Path.DirectorySeparatorChar) != -1)
					parentDir = Path.GetDirectoryName (filePath);
				else
					parentDir = filePath;
			}

			FileChangeNotificationSystemEntry entry;
			lock (watchers_lock) {
				Dictionary <string, FileChangeNotificationSystemEntry> watchers = Watchers;

				if (!watchers.TryGetValue (parentDir, out entry)) {
					entry = new FileChangeNotificationSystemEntry (parentDir, this);
					watchers.Add (parentDir, entry);
				}

				entry.Add (filePath);
				entry.Start ();
			}

			state = entry;
		}