FileSystemWatcher.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. : this (String.Empty, String.Empty)
  26. {
  27. }
  28. public FileSystemWatcher (string path)
  29. : this (path, String.Empty)
  30. {
  31. }
  32. [MonoTODO]
  33. public FileSystemWatcher (string path, string filter)
  34. {
  35. if (path == null)
  36. throw new ArgumentNullException ();
  37. if (filter == null)
  38. throw new ArgumentNullException ();
  39. if (path == String.Empty)
  40. throw new ArgumentException ();
  41. // if the path does not exist throw an ArgumentException
  42. this.enableRaisingEvents = false;
  43. this.filter = filter;
  44. this.includeSubdirectories = false;
  45. this.internalBufferSize = 8192;
  46. this.notifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
  47. this.path = path;
  48. this.synchronizingObject = null;
  49. }
  50. #endregion // Constructors
  51. #region Properties
  52. public bool EnableRaisingEvents {
  53. get { return enableRaisingEvents; }
  54. set { enableRaisingEvents = value; }
  55. }
  56. public string Filter {
  57. get { return filter; }
  58. set { filter = value; }
  59. }
  60. public bool IncludeSubdirectories {
  61. get { return includeSubdirectories; }
  62. set { includeSubdirectories = value; }
  63. }
  64. public int InternalBufferSize {
  65. get { return internalBufferSize; }
  66. set { internalBufferSize = value; }
  67. }
  68. public NotifyFilters NotifyFilter {
  69. get { return notifyFilter; }
  70. [MonoTODO ("Perform validation.")]
  71. set { notifyFilter = value; }
  72. }
  73. public string Path {
  74. get { return path; }
  75. [MonoTODO ("Perform validation.")]
  76. set { path = value; }
  77. }
  78. public override ISite Site {
  79. get { return site; }
  80. set { site = value; }
  81. }
  82. public ISynchronizeInvoke SynchronizingObject {
  83. get { return synchronizingObject; }
  84. set { synchronizingObject = value; }
  85. }
  86. #endregion // Properties
  87. #region Methods
  88. [MonoTODO]
  89. public void BeginInit ()
  90. {
  91. throw new NotImplementedException ();
  92. }
  93. [MonoTODO]
  94. protected override void Dispose (bool disposing)
  95. {
  96. throw new NotImplementedException ();
  97. }
  98. [MonoTODO]
  99. public void EndInit ()
  100. {
  101. throw new NotImplementedException ();
  102. }
  103. [MonoTODO]
  104. protected void OnChanged (FileSystemEventArgs e)
  105. {
  106. throw new NotImplementedException ();
  107. }
  108. [MonoTODO]
  109. protected void OnCreated (FileSystemEventArgs e)
  110. {
  111. throw new NotImplementedException ();
  112. }
  113. [MonoTODO]
  114. protected void OnDeleted (FileSystemEventArgs e)
  115. {
  116. throw new NotImplementedException ();
  117. }
  118. [MonoTODO]
  119. protected void OnError (ErrorEventArgs e)
  120. {
  121. throw new NotImplementedException ();
  122. }
  123. [MonoTODO]
  124. protected void OnRenamed (RenamedEventArgs e)
  125. {
  126. throw new NotImplementedException ();
  127. }
  128. [MonoTODO]
  129. public WaitForChangedResult WaitForChanged (WatcherChangeTypes changeType)
  130. {
  131. throw new NotImplementedException ();
  132. }
  133. [MonoTODO]
  134. public WaitForChangedResult WaitForChanged (WatcherChangeTypes changeType, int timeout)
  135. {
  136. throw new NotImplementedException ();
  137. }
  138. #endregion // Methods
  139. #region Events and Delegates
  140. public event FileSystemEventHandler Changed;
  141. public event FileSystemEventHandler Created;
  142. public event FileSystemEventHandler Deleted;
  143. public event ErrorEventHandler Error;
  144. public event RenamedEventHandler Renamed;
  145. #endregion // Events and Delegates
  146. }
  147. }