DirectoryNotFoundException Oluşturucular

Tanım

İleti dizesiyle sınıfının yeni bir örneğini DirectoryNotFoundException başlatır.

Aşırı Yüklemeler

DirectoryNotFoundException()

İleti dizesi sistem tarafından sağlanan bir iletiye, HRESULT'ı da COR_E_DIRECTORYNOTFOUND olarak ayarlanmış şekilde sınıfın yeni bir örneğini DirectoryNotFoundException başlatır.

DirectoryNotFoundException(String)

İleti dizesi olarak ve HRESULT COR_E_DIRECTORYNOTFOUND olarak ayarlanmış message şekilde sınıfının yeni bir örneğini DirectoryNotFoundException başlatır.

DirectoryNotFoundException(SerializationInfo, StreamingContext)
Geçersiz.

Belirtilen serileştirme ve bağlam bilgileriyle sınıfının yeni bir örneğini DirectoryNotFoundException başlatır.

DirectoryNotFoundException(String, Exception)

Belirtilen bir hata iletisi ve bu özel durumun nedeni olan iç özel duruma başvuru ile sınıfının yeni bir örneğini DirectoryNotFoundException başlatır.

DirectoryNotFoundException()

Kaynak:
DirectoryNotFoundException.cs
Kaynak:
DirectoryNotFoundException.cs
Kaynak:
DirectoryNotFoundException.cs

İleti dizesi sistem tarafından sağlanan bir iletiye, HRESULT'ı da COR_E_DIRECTORYNOTFOUND olarak ayarlanmış şekilde sınıfın yeni bir örneğini DirectoryNotFoundException başlatır.

public:
 DirectoryNotFoundException();
public DirectoryNotFoundException ();
Public Sub New ()

Örnekler

Aşağıdaki kod örneği oluşturucunun nasıl çağrılduğunu DirectoryNotFoundException gösterir.

using System;
using System.IO;

class Program
{

    static void Main(string[] args)
    {
        try
        {

            //  Specify a directory name that does not exist for this demo.
            string dir = @"c:\78fe9lk";

            // If this directory does not exist, a DirectoryNotFoundException is thrown
            // when attempting to set the current directory.
            Directory.SetCurrentDirectory(dir);
        }
        catch (DirectoryNotFoundException dirEx)
        {
            // Let the user know that the directory did not exist.
            Console.WriteLine("Directory not found: " + dirEx.Message);
        }
    }
}
Imports System.IO

Module Module1
    Sub Main()
        Try

            ' Specify a directory name that does not exist for this demo.
            Dim dir As String = "c:\78fe9lk"

            ' If this directory does not exist, a DirectoryNotFoundException is thrown
            ' when attempting to set the current directory.
            Directory.SetCurrentDirectory(dir)

        Catch ex As System.IO.DirectoryNotFoundException

            ' Let the user know that the directory did not exist.
            Console.WriteLine("Directory not found: " + ex.Message)
        End Try
    End Sub
End Module

Açıklamalar

Bu oluşturucu, yeni örneğin özelliğini sistem tarafından sağlanan ve "Belirtilen dizin bulunamadı" gibi hatayı açıklayan bir iletiye başlatır Exception.Message . Bu ileti geçerli sistem kültürünü dikkate alır.

Exception.InnerException Yeni örneğin özelliği olarak nullbaşlatılır.

Ayrıca bkz.

Şunlara uygulanır

DirectoryNotFoundException(String)

Kaynak:
DirectoryNotFoundException.cs
Kaynak:
DirectoryNotFoundException.cs
Kaynak:
DirectoryNotFoundException.cs

İleti dizesi olarak ve HRESULT COR_E_DIRECTORYNOTFOUND olarak ayarlanmış message şekilde sınıfının yeni bir örneğini DirectoryNotFoundException başlatır.

public:
 DirectoryNotFoundException(System::String ^ message);
public DirectoryNotFoundException (string message);
public DirectoryNotFoundException (string? message);
new System.IO.DirectoryNotFoundException : string -> System.IO.DirectoryNotFoundException
Public Sub New (message As String)

Parametreler

message
String

String Hatayı açıklayan bir. içeriğinin message insanlar tarafından anlaşılması amaçlanmıştır. Bu yapıcının çağırıcısı, bu dizenin geçerli sistem kültürü için yerelleştirilmiş olduğundan emin olmak için gereklidir.

Açıklamalar

Bu oluşturucu kullanarak messageyeni örneğin özelliğini başlatırException.Message.

Exception.InnerException Yeni örneğin özelliği olarak nullbaşlatılır.

Ayrıca bkz.

Şunlara uygulanır

DirectoryNotFoundException(SerializationInfo, StreamingContext)

Kaynak:
DirectoryNotFoundException.cs
Kaynak:
DirectoryNotFoundException.cs
Kaynak:
DirectoryNotFoundException.cs

Dikkat

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Belirtilen serileştirme ve bağlam bilgileriyle sınıfının yeni bir örneğini DirectoryNotFoundException başlatır.

protected:
 DirectoryNotFoundException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected DirectoryNotFoundException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected DirectoryNotFoundException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.IO.DirectoryNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.IO.DirectoryNotFoundException
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.IO.DirectoryNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.IO.DirectoryNotFoundException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parametreler

info
SerializationInfo

Oluşturulan özel durumla ilgili serileştirilmiş nesne verilerini içeren SerializationInfo.

context
StreamingContext

Kaynak veya hedefle ilgili bağlamsal bilgileri içeren StreamingContext.

Öznitelikler

Ayrıca bkz.

Şunlara uygulanır

DirectoryNotFoundException(String, Exception)

Kaynak:
DirectoryNotFoundException.cs
Kaynak:
DirectoryNotFoundException.cs
Kaynak:
DirectoryNotFoundException.cs

Belirtilen bir hata iletisi ve bu özel durumun nedeni olan iç özel duruma başvuru ile sınıfının yeni bir örneğini DirectoryNotFoundException başlatır.

public:
 DirectoryNotFoundException(System::String ^ message, Exception ^ innerException);
public DirectoryNotFoundException (string message, Exception innerException);
public DirectoryNotFoundException (string? message, Exception? innerException);
new System.IO.DirectoryNotFoundException : string * Exception -> System.IO.DirectoryNotFoundException
Public Sub New (message As String, innerException As Exception)

Parametreler

message
String

Özel durumun nedenini açıklayan hata iletisi.

innerException
Exception

Geçerli özel durumun nedeni olan özel durum. innerException parametresi değilsenull, geçerli özel durum iç özel durumu işleyen bir catch blokta oluşturulur.

Açıklamalar

Bir önceki özel durumun doğrudan bir sonucu olarak oluşturulan bir özel durum, InnerException özelliğindeki önceki özel duruma başvuru içermelidir. InnerException özelliği, oluşturucuya iletilen aynı değeri ya da InnerException özelliği oluşturucuya iç özel durum değeri sağlamıyorsa null değerini döndürür.

Aşağıdaki tablo, DirectoryNotFoundException öğesinin bir örneği için başlangıç özellik değerlerini gösterir.

Özellik Değer
InnerException İç özel duruma başvuru.
Message Hata iletisi dizesi.

Ayrıca bkz.

Şunlara uygulanır