InternalBufferOverflowException 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
내부 버퍼가 오버플로되는 경우 throw되는 예외입니다.
public ref class InternalBufferOverflowException : SystemException
public class InternalBufferOverflowException : SystemException
[System.Serializable]
public class InternalBufferOverflowException : SystemException
type InternalBufferOverflowException = class
inherit SystemException
[<System.Serializable>]
type InternalBufferOverflowException = class
inherit SystemException
Public Class InternalBufferOverflowException
Inherits SystemException
- 상속
- 특성
예제
다음 예제에서는 디스크 드라이브에서 발생하는 파일 변경 내용(만들기, 삭제, 이름 바꾸기, 변경)을 모니터링하는 FileSystemWatcher를 만드는 방법을 보여 줍니다. 이 예제에서는 오류 알림을 제대로 수신하는 방법도 보여 줍니다.
using System;
using System.IO;
class Program
{
static void Main(string[] args)
{
// Create a FileSystemWatcher to monitor all files on drive C.
FileSystemWatcher fsw = new FileSystemWatcher("C:\\");
// Watch for changes in LastAccess and LastWrite times, and
// the renaming of files or directories.
fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName |NotifyFilters.DirectoryName;
// Register a handler that gets called when a
// file is created, changed, or deleted.
fsw.Changed += new FileSystemEventHandler(OnChanged);
fsw.Created += new FileSystemEventHandler(OnChanged);
fsw.Deleted += new FileSystemEventHandler(OnChanged);
// Register a handler that gets called when a file is renamed.
fsw.Renamed += new RenamedEventHandler(OnRenamed);
// Register a handler that gets called if the
// FileSystemWatcher needs to report an error.
fsw.Error += new ErrorEventHandler(OnError);
// Begin watching.
fsw.EnableRaisingEvents = true;
Console.WriteLine("Press \'Enter\' to quit the sample.");
Console.ReadLine();
}
// This method is called when a file is created, changed, or deleted.
private static void OnChanged(object source, FileSystemEventArgs e)
{
// Show that a file has been created, changed, or deleted.
WatcherChangeTypes wct = e.ChangeType;
Console.WriteLine("File {0} {1}", e.FullPath, wct.ToString());
}
// This method is called when a file is renamed.
private static void OnRenamed(object source, RenamedEventArgs e)
{
// Show that a file has been renamed.
WatcherChangeTypes wct = e.ChangeType;
Console.WriteLine("File {0} {2} to {1}", e.OldFullPath, e.FullPath, wct.ToString());
}
// This method is called when the FileSystemWatcher detects an error.
private static void OnError(object source, ErrorEventArgs e)
{
// Show that an error has been detected.
Console.WriteLine("The FileSystemWatcher has detected an error");
// Give more information if the error is due to an internal buffer overflow.
if (e.GetException().GetType() == typeof(InternalBufferOverflowException))
{
// This can happen if Windows is reporting many file system events quickly
// and internal buffer of the FileSystemWatcher is not large enough to handle this
// rate of events. The InternalBufferOverflowException error informs the application
// that some of the file system events are being lost.
Console.WriteLine(("The file system watcher experienced an internal buffer overflow: " + e.GetException().Message));
}
}
}
Imports System.IO
Module Module1
Sub Main()
' Create a FileSystemWatcher to monitor all files on drive C.
Dim fsw As New FileSystemWatcher("C:\")
' Watch for changes in LastAccess and LastWrite times, and
' the renaming of files or directories.
fsw.NotifyFilter = (NotifyFilters.LastAccess Or NotifyFilters.LastWrite _
Or NotifyFilters.FileName Or NotifyFilters.DirectoryName)
' Register a handler that gets called when a
' file is created, changed, or deleted.
AddHandler fsw.Changed, New FileSystemEventHandler(AddressOf OnChanged)
' The commented line of code below is a shorthand of the above line.
' AddHandler fsw.Changed, AddressOf OnChanged
' NOTE: The shorthand version is used in the remainder of this code.
' FileSystemEventHandler
AddHandler fsw.Created, AddressOf OnChanged
' FileSystemEventHandler
AddHandler fsw.Deleted, AddressOf OnChanged
' Register a handler that gets called when a file is renamed.
' RenamedEventHandler
AddHandler fsw.Renamed, AddressOf OnRenamed
' Register a handler that gets called if the
' FileSystemWatcher needs to report an error.
' ErrorEventHandler
AddHandler fsw.Error, AddressOf OnError
' Begin watching.
fsw.EnableRaisingEvents = True
' Wait for the user to quit the program.
Console.WriteLine("Press 'Enter' to quit the sample.")
Console.ReadLine()
End Sub
' This method is called when a file is created, changed, or deleted.
Private Sub OnChanged(ByVal source As Object, ByVal e As FileSystemEventArgs)
' Show that a file has been created, changed, or deleted.
Dim wct As WatcherChangeTypes = e.ChangeType
Console.WriteLine("File {0} {1}", e.FullPath, wct.ToString())
End Sub
' This method is called when a file is renamed.
Private Sub OnRenamed(ByVal source As Object, ByVal e As RenamedEventArgs)
' Show that a file has been renamed.
Dim wct As WatcherChangeTypes = e.ChangeType
Console.WriteLine("File {0} {2} to {1}", e.OldFullPath, e.FullPath, wct.ToString())
End Sub
' This method is called when the FileSystemWatcher detects an error.
Private Sub OnError(ByVal source As Object, ByVal e As ErrorEventArgs)
' Show that an error has been detected.
Console.WriteLine("The FileSystemWatcher has detected an error")
' Give more information if the error is due to an internal buffer overflow.
If TypeOf e.GetException Is InternalBufferOverflowException Then
' This can happen if Windows is reporting many file system events quickly
' and internal buffer of the FileSystemWatcher is not large enough to handle this
' rate of events. The InternalBufferOverflowException error informs the application
' that some of the file system events are being lost.
Console.WriteLine( _
"The file system watcher experienced an internal buffer overflow: " _
+ e.GetException.Message)
End If
End Sub
End Module
설명
FileSystemWatcher에서 파일 변경에 대한 알림을 받으면 시스템은 구성 요소가 만들고 API(애플리케이션 프로그래밍 인터페이스)에 전달하는 버퍼에 해당 변경 내용을 저장합니다. 짧은 시간에 많은 변경 내용이 있는 경우 버퍼가 쉽게 오버플로되어 예외가 throw되어 기본적으로 모든 변경 내용이 손실될 수 있습니다. 버퍼가 오버플로되지 않도록 하려면 해당 및 FileSystemWatcher.IncludeSubdirectories 속성을 사용하여 FileSystemWatcher.NotifyFilter 원치 않는 변경 알림을 필터링합니다. 속성을 통해 FileSystemWatcher.InternalBufferSize 내부 버퍼의 크기를 늘릴 수도 있습니다. 그러나 버퍼의 크기를 늘리면 비용이 많이 들므로 버퍼를 가능한 한 작게 유지합니다.
생성자
| Name | Description |
|---|---|
| InternalBufferOverflowException() |
클래스의 새 기본 인스턴스를 초기화합니다 InternalBufferOverflowException . |
| InternalBufferOverflowException(SerializationInfo, StreamingContext) |
사용되지 않음.
지정된 개체와 StreamingContext 개체를 사용하여 직렬화할 수 있는 클래스의 InternalBufferOverflowException 빈 새 인스턴스를 SerializationInfo 초기화합니다. |
| InternalBufferOverflowException(String, Exception) |
표시할 메시지와 생성된 내부 예외를 지정하여 클래스의 새 인스턴스 InternalBufferOverflowException 를 초기화합니다. |
| InternalBufferOverflowException(String) |
지정한 오류 메시지를 사용하여 클래스의 InternalBufferOverflowException 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| Data |
예외에 대한 추가 사용자 정의 정보를 제공하는 키/값 쌍의 컬렉션을 가져옵니다. (다음에서 상속됨 Exception) |
| HelpLink |
이 예외와 연결된 도움말 파일에 대한 링크를 가져오거나 설정합니다. (다음에서 상속됨 Exception) |
| HResult |
특정 예외에 할당된 코딩된 숫자 값인 HRESULT를 가져오거나 설정합니다. (다음에서 상속됨 Exception) |
| InnerException |
현재 예외를 Exception 발생시킨 인스턴스를 가져옵니다. (다음에서 상속됨 Exception) |
| Message |
현재 예외를 설명하는 메시지를 가져옵니다. (다음에서 상속됨 Exception) |
| Source |
오류를 발생시키는 애플리케이션 또는 개체의 이름을 가져오거나 설정합니다. (다음에서 상속됨 Exception) |
| StackTrace |
호출 스택에서 직접 실행 프레임의 문자열 표현을 가져옵니다. (다음에서 상속됨 Exception) |
| TargetSite |
현재 예외를 throw하는 메서드를 가져옵니다. (다음에서 상속됨 Exception) |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
지정된 개체가 현재 개체와 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetBaseException() |
파생 클래스에서 재정의되는 경우 하나 이상의 후속 예외의 근본 원인인 값을 반환 Exception 합니다. (다음에서 상속됨 Exception) |
| GetHashCode() |
기본 해시 함수로 사용됩니다. (다음에서 상속됨 Object) |
| GetObjectData(SerializationInfo, StreamingContext) |
사용되지 않음.
파생 클래스에서 재정의되는 경우 예외에 SerializationInfo 대한 정보를 사용하여 설정합니다. (다음에서 상속됨 Exception) |
| GetType() |
현재 인스턴스의 런타임 형식을 가져옵니다. (다음에서 상속됨 Exception) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 예외의 문자열 표현을 만들고 반환합니다. (다음에서 상속됨 Exception) |
이벤트
| Name | Description |
|---|---|
| SerializeObjectState |
사용되지 않음.
예외에 대한 직렬화된 데이터를 포함하는 예외 상태 개체를 만들기 위해 예외가 serialize될 때 발생합니다. (다음에서 상속됨 Exception) |