Sideway
output.to from Sideway
Draft for Information Only

Content

I/O Watcher
 FileSystemWatcher Class 
  Constructors
  Properties
  Methods
  Events
  Security
  Remarks
  Applies to
  See also
 WatcherChangeTypes Enum
  Fields
  Remarks
  Applies to
  See also
 NotifyFilters Enum
  Fields
  Remarks
  Applies to
  See also
 WaitForChangedResult Struct
  Properties
  Applies to
  See also
 Source/Reference

I/O Watcher

The I/O Watcher components used in .NET framework is FileSystemWatcher, WatcherChangeTypes, NotifyFilters, and WaitForChangedResult.

FileSystemWatcher Class 

Listens to the file system change notifications and raises events when a directory, or file in a directory, changes.

NamespaceSystem.IO AssembliesSystem.IO.FileSystem.Watcher.dll, System.dll, netstandard.dll
[System.IO.IODescription("")]
[System.IO.IODescription("FileSystemWatcherDesc")]
public class FileSystemWatcher : System.ComponentModel.Component, System.ComponentModel.ISupportInitialize

Inheritance: Object->->->MarshalByRefObject->Component->FileSystemWatcher

Attributes: IODescriptionAttribute, IODescriptionAttribute

Implements: ISupportInitialize

Constructors

FileSystemWatcher()

Initializes a new instance of the FileSystemWatcher class.

FileSystemWatcher(String)

Initializes a new instance of the FileSystemWatcher class, given the specified directory to monitor.

FileSystemWatcher(String, String)

Initializes a new instance of the FileSystemWatcher class, given the specified directory and type of files to monitor.

Properties

CanRaiseEvents

Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Container

Gets the IContainer that contains the Component.

(Inherited from Component)
DesignMode

Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
EnableRaisingEvents

Gets or sets a value indicating whether the component is enabled.

Events

Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
Filter

Gets or sets the filter string used to determine what files are monitored in a directory.

IncludeSubdirectories

Gets or sets a value indicating whether subdirectories within the specified path should be monitored.

InternalBufferSize

Gets or sets the size (in bytes) of the internal buffer.

NotifyFilter

Gets or sets the type of changes to watch for.

Path

Gets or sets the path of the directory to watch.

Site

Gets or sets an ISite for the FileSystemWatcher.

SynchronizingObject

Gets or sets the object used to marshal the event handler calls issued as a result of a directory change.

Methods

BeginInit()

Begins the initialization of a FileSystemWatcher used on a form or used by another component. The initialization occurs at run time.

CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose(Boolean)

Releases the unmanaged resources used by the FileSystemWatcher and optionally releases the managed resources.

EndInit()

Ends the initialization of a FileSystemWatcher used on a form or used by another component. The initialization occurs at run time.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type)

Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
OnChanged(FileSystemEventArgs)

Raises the Changed event.

OnCreated(FileSystemEventArgs)

Raises the Created event.

OnDeleted(FileSystemEventArgs)

Raises the Deleted event.

OnError(ErrorEventArgs)

Raises the Error event.

OnRenamed(RenamedEventArgs)

Raises the Renamed event.

ToString()

Returns a String containing the name of the Component, if any. This method should not be overridden.

(Inherited from Component)
WaitForChanged(WatcherChangeTypes)

A synchronous method that returns a structure that contains specific information on the change that occurred, given the type of change you want to monitor.

WaitForChanged(WatcherChangeTypes, Int32)

A synchronous method that returns a structure that contains specific information on the change that occurred, given the type of change you want to monitor and the time (in milliseconds) to wait before timing out.

Events

Changed

Occurs when a file or directory in the specified Path is changed.

Created

Occurs when a file or directory in the specified Path is created.

Deleted

Occurs when a file or directory in the specified Path is deleted.

Disposed

Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)
Error

Occurs when the instance of FileSystemWatcher is unable to continue monitoring changes or when the internal buffer overflows.

Renamed

Occurs when a file or directory in the specified Path is renamed.

Security

SecurityPermission
for deriving from the ProcessStartInfo class. Demand value: InheritanceDemand; Named Permission Sets: FullTrust.

Remarks

  • Use FileSystemWatcher to watch for changes in a specified directory. You can watch for changes in files and subdirectories of the specified directory. You can create a component to watch files on a local computer, a network drive, or a remote computer.

    To watch for changes in all files, set the Filter property to an empty string ("") or use wildcards ("*.*"). To watch a specific file, set the Filter property to the file name. For example, to watch for changes in the file MyDoc.txt, set the Filter property to "MyDoc.txt". You can also watch for changes in a certain type of file. For example, to watch for changes in text files, set the Filter property to "*.txt".

    There are several types of changes you can watch for in a directory or file. For example, you can watch for changes in Attributes, the LastWrite date and time, or the Size of files or directories. This is done by setting the NotifyFilter property to one of the NotifyFilters values. For more information on the type of changes you can watch, see NotifyFilters.

    You can watch for renaming, deletion, or creation of files or directories. For example, to watch for renaming of text files, set the Filter property to "*.txt" and call the WaitForChanged method with a Renamed specified for its parameter.

    The Windows operating system notifies your component of file changes in a buffer created by the FileSystemWatcher. If there are many changes in a short time, the buffer can overflow. This causes the component to lose track of changes in the directory, and it will only provide blanket notification. Increasing the size of the buffer with the InternalBufferSize property is expensive, as it comes from non-paged memory that cannot be swapped out to disk, so keep the buffer as small yet large enough to not miss any file change events. To avoid a buffer overflow, use the NotifyFilter and IncludeSubdirectories properties so you can filter out unwanted change notifications.

    For a list of initial property values for an instance of FileSystemWatcher, see the FileSystemWatcher constructor.

    Please note the following when using the FileSystemWatcher class.

    • Hidden files are not ignored.

    • In some systems, FileSystemWatcher reports changes to files using the short 8.3 file name format. For example, a change to "LongFileName.LongExtension" could be reported as "LongFil~.Lon".

    • This class contains a link demand and an inheritance demand at the class level that applies to all members. A SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see Link Demands.

    • The maximum size you can set for the InternalBufferSize property for monitoring a directory over the network is 64 KB.

    Note

    Running FileSystemWatcher on Windows 98 is not supported.

    Copying and moving folders

    The operating system and FileSystemWatcher object interpret a cut-and-paste action or a move action as a rename action for a folder and its contents. If you cut and paste a folder with files into a folder being watched, the FileSystemWatcher object reports only the folder as new, but not its contents because they are essentially only renamed.

    To be notified that the contents of folders have been moved or copied into a watched folder, provide OnChanged and OnRenamed event handler methods as suggested in the following table.

    Event Handler Events Handled Performs
    OnChanged Changed, Created, Deleted Report changes in file attributes, created files, and deleted files.
    OnRenamed Renamed List the old and new paths of renamed files and folders, expanding recursively if needed.

    Events and Buffer Sizes

    Note that several factors can affect which file system change events are raised, as described by the following:

    • Common file system operations might raise more than one event. For example, when a file is moved from one directory to another, several OnChanged and some OnCreated and OnDeleted events might be raised. Moving a file is a complex operation that consists of multiple simple operations, therefore raising multiple events. Likewise, some applications (for example, antivirus software) might cause additional file system events that are detected by FileSystemWatcher.

    • The FileSystemWatcher can watch disks as long as they are not switched or removed. The FileSystemWatcher does not raise events for CDs and DVDs, because time stamps and properties cannot change. Remote computers must have one of the required platforms installed for the component to function properly.

    • If multiple FileSystemWatcher objects are watching the same UNC path in Windows XP prior to Service Pack 1, or Windows 2000 SP2 or earlier, then only one of the objects will raise an event. On machines running Windows XP SP1 and newer, Windows 2000 SP3 or newer or Windows Server 2003, all FileSystemWatcher objects will raise the appropriate events.

    Note that a FileSystemWatcher may miss an event when the buffer size is exceeded. To avoid missing events, follow these guidelines:

    • Increase the buffer size by setting the InternalBufferSize property.

    • Avoid watching files with long file names, because a long file name contributes to filling up the buffer. Consider renaming these files using shorter names.

    • Keep your event handling code as short as possible.

Applies to

.NET Framework: 4.8, 4.7.2, 4.7.1, 4.7, 4.6.2, 4.6.1, 4.6, 4.5.2, 4.5.1, 4.5, 4.0, 3.5, 3.0, 2.0, 1.1

See also

WatcherChangeTypes Enum

Changes that might occur to a file or directory.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

NamespaceSystem.IO AssembliesSystem.IO.FileSystem.Watcher.dll, System.dll, netstandard.dll
[System.Flags]
public enum WatcherChangeTypes

Inheritance: Object->ValueType->Enum->WatcherChangeTypes

Attributes: FlagsAttribute,

Fields

All 15

The creation, deletion, change, or renaming of a file or folder.

Changed 4

The change of a file or folder. The types of changes include: changes to size, attributes, security settings, last write, and last access time.

Created 1

The creation of a file or folder.

Deleted 2

The deletion of a file or folder.

Renamed 8

The renaming of a file or folder.

Remarks

Applies to

.NET Framework: 4.8, 4.7.2, 4.7.1, 4.7, 4.6.2, 4.6.1, 4.6, 4.5.2, 4.5.1, 4.5, 4.0, 3.5, 3.0, 2.0, 1.1

See also

NotifyFilters Enum

Specifies changes to watch for in a file or folder.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

NamespaceSystem.IO AssembliesSystem.IO.FileSystem.Watcher.dll, System.dll, netstandard.dll
[System.Flags]
public enum NotifyFilters

Inheritance: Object->ValueType->Enum->NotifyFilters

Attributes: FlagsAttribute,

Fields

Attributes 4

The attributes of the file or folder.

CreationTime 64

The time the file or folder was created.

DirectoryName 2

The name of the directory.

FileName 1

The name of the file.

LastAccess 32

The date the file or folder was last opened.

LastWrite 16

The date the file or folder last had anything written to it.

Security 256

The security settings of the file or folder.

Size 8

The size of the file or folder.

Remarks

  • You can combine the members of this enumeration to watch for more than one kind of change. For example, you can watch for changes in the size of a file or folder, and for changes in security settings. This raises an event anytime there is a change in size or security settings of a file or folder.

Applies to

.NET Framework: 4.8, 4.7.2, 4.7.1, 4.7, 4.6.2, 4.6.1, 4.6, 4.5.2, 4.5.1, 4.5, 4.0, 3.5, 3.0, 2.0, 1.1

See also

WaitForChangedResult Struct

Contains information on the change that occurred.

NamespaceSystem.IO AssembliesSystem.IO.FileSystem.Watcher.dll, System.dll, netstandard.dll
public struct WaitForChangedResult

Inheritance: Object->->ValueType->WaitForChangedResult

Properties

ChangeType

Gets or sets the type of change that occurred.

Name

Gets or sets the name of the file or directory that changed.

OldName

Gets or sets the original name of the file or directory that was renamed.

TimedOut

Gets or sets a value indicating whether the wait operation timed out.

Applies to

.NET Framework: 4.8, 4.7.2, 4.7.1, 4.7, 4.6.2, 4.6.1, 4.6, 4.5.2, 4.5.1, 4.5, 4.0, 3.5, 3.0, 2.0, 1.1

See also

Source/Reference


©sideway

ID: 200700017 Last Updated: 7/17/2020 Revision: 0 Ref:

close

References

  1. Active Server Pages,  , http://msdn.microsoft.com/en-us/library/aa286483.aspx
  2. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
  3. ASP Best Practices,  , http://technet.microsoft.com/en-us/library/cc939157.aspx
  4. ASP Built-in Objects,  , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
  5. Response Object,  , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
  6. Request Object,  , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
  7. Server Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
  8. Application Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
  9. Session Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
  10. ASPError Object,  , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
  11. ObjectContext Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
  12. Debugging Global.asa Files,  , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
  13. How to: Debug Global.asa files,  , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
  14. Calling COM Components from ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
  15. IIS ASP Scripting Reference,  , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
  16. ASP Keywords,  , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
  17. Creating Simple ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
  18. Including Files in ASP Applications,  , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
  19. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
  20. FileSystemObject Object,  , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  , ADO Object Model
  22. ADO Fundamentals,  , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx
close

Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019