FileSystemWatcher.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. //
  2. // System.IO.FileSystemWatcher.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2002
  8. //
  9. using System;
  10. using System.ComponentModel;
  11. namespace System.IO {
  12. public class FileSystemWatcher : Component, ISupportInitialize {
  13. #region Fields
  14. bool enableRaisingEvents;
  15. string filter;
  16. bool includeSubdirectories;
  17. int internalBufferSize;
  18. NotifyFilters notifyFilter;
  19. string path;
  20. ISite site;
  21. ISynchronizeInvoke synchronizingObject;
  22. #endregion // Fields
  23. #region Constructors
  24. public FileSystemWatcher ()
  25. {
  26. this.notifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
  27. this.enableRaisingEvents = false;
  28. this.filter = "*.*";
  29. this.includeSubdirectories = false;
  30. this.internalBufferSize = 8192;
  31. this.path = "";
  32. }
  33. public FileSystemWatcher (string path)
  34. : this (path, String.Empty)
  35. {
  36. }
  37. [MonoTODO]
  38. public FileSystemWatcher (string path, string filter)
  39. {
  40. if (path == null)
  41. throw new ArgumentNullException ();
  42. if (filter == null)
  43. throw new ArgumentNullException ();
  44. if (path == String.Empty)
  45. throw new ArgumentException ();
  46. // if the path does not exist throw an ArgumentException
  47. this.enableRaisingEvents = false;
  48. this.filter = filter;
  49. this.includeSubdirectories = false;
  50. this.internalBufferSize = 8192;
  51. this.notifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
  52. this.path = path;
  53. this.synchronizingObject = null;
  54. }
  55. #endregion // Constructors
  56. #region Properties
  57. public bool EnableRaisingEvents {
  58. get { return enableRaisingEvents; }
  59. set { enableRaisingEvents = value; }
  60. }
  61. public string Filter {
  62. get { return filter; }
  63. set { filter = value; }
  64. }
  65. public bool IncludeSubdirectories {
  66. get { return includeSubdirectories; }
  67. set { includeSubdirectories = value; }
  68. }
  69. public int InternalBufferSize {
  70. get { return internalBufferSize; }
  71. set { internalBufferSize = value; }
  72. }
  73. public NotifyFilters NotifyFilter {
  74. get { return notifyFilter; }
  75. [MonoTODO ("Perform validation.")]
  76. set { notifyFilter = value; }
  77. }
  78. public string Path {
  79. get { return path; }
  80. [MonoTODO ("Perform validation.")]
  81. set { path = value; }
  82. }
  83. public override ISite Site {
  84. get { return site; }
  85. set { site = value; }
  86. }
  87. public ISynchronizeInvoke SynchronizingObject {
  88. get { return synchronizingObject; }
  89. set { synchronizingObject = value; }
  90. }
  91. #endregion // Properties
  92. #region Methods
  93. [MonoTODO]
  94. public void BeginInit ()
  95. {
  96. throw new NotImplementedException ();
  97. }
  98. [MonoTODO]
  99. protected override void Dispose (bool disposing)
  100. {
  101. if (disposing) {
  102. //
  103. }
  104. base.Dispose (disposing);
  105. }
  106. [MonoTODO]
  107. public void EndInit ()
  108. {
  109. throw new NotImplementedException ();
  110. }
  111. [MonoTODO]
  112. protected void OnChanged (FileSystemEventArgs e)
  113. {
  114. throw new NotImplementedException ();
  115. }
  116. [MonoTODO]
  117. protected void OnCreated (FileSystemEventArgs e)
  118. {
  119. throw new NotImplementedException ();
  120. }
  121. [MonoTODO]
  122. protected void OnDeleted (FileSystemEventArgs e)
  123. {
  124. throw new NotImplementedException ();
  125. }
  126. [MonoTODO]
  127. protected void OnError (ErrorEventArgs e)
  128. {
  129. throw new NotImplementedException ();
  130. }
  131. [MonoTODO]
  132. protected void OnRenamed (RenamedEventArgs e)
  133. {
  134. throw new NotImplementedException ();
  135. }
  136. [MonoTODO]
  137. public WaitForChangedResult WaitForChanged (WatcherChangeTypes changeType)
  138. {
  139. throw new NotImplementedException ();
  140. }
  141. [MonoTODO]
  142. public WaitForChangedResult WaitForChanged (WatcherChangeTypes changeType, int timeout)
  143. {
  144. throw new NotImplementedException ();
  145. }
  146. #endregion // Methods
  147. #region Events and Delegates
  148. public event FileSystemEventHandler Changed;
  149. public event FileSystemEventHandler Created;
  150. public event FileSystemEventHandler Deleted;
  151. public event ErrorEventHandler Error;
  152. public event RenamedEventHandler Renamed;
  153. #endregion // Events and Delegates
  154. }
  155. }