Partager via


DirectoryNotFoundException Constructeurs

Définition

Initialise une nouvelle instance de la DirectoryNotFoundException classe avec sa chaîne de message.

Surcharges

Nom Description
DirectoryNotFoundException()

Initialise une nouvelle instance de la DirectoryNotFoundException classe avec sa chaîne de message définie sur un message fourni par le système et son HRESULT défini sur COR_E_DIRECTORYNOTFOUND.

DirectoryNotFoundException(String)

Initialise une nouvelle instance de la DirectoryNotFoundException classe avec sa chaîne de message définie message sur et son HRESULT défini sur COR_E_DIRECTORYNOTFOUND.

DirectoryNotFoundException(SerializationInfo, StreamingContext)
Obsolète.

Initialise une nouvelle instance de la DirectoryNotFoundException classe avec les informations de sérialisation et de contexte spécifiées.

DirectoryNotFoundException(String, Exception)

Initialise une nouvelle instance de la DirectoryNotFoundException classe avec un message d’erreur spécifié et une référence à l’exception interne qui est la cause de cette exception.

DirectoryNotFoundException()

Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs

Initialise une nouvelle instance de la DirectoryNotFoundException classe avec sa chaîne de message définie sur un message fourni par le système et son HRESULT défini sur COR_E_DIRECTORYNOTFOUND.

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

Exemples

L’exemple de code suivant montre comment appeler le DirectoryNotFoundException constructeur.

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

Remarques

Ce constructeur initialise la Exception.Message propriété de la nouvelle instance dans un message fourni par le système qui décrit l’erreur, par exemple « Impossible de trouver le répertoire spécifié ». Ce message prend en compte la culture système actuelle.

La Exception.InnerException propriété de la nouvelle instance est initialisée sur null.

Voir aussi

S’applique à

DirectoryNotFoundException(String)

Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs

Initialise une nouvelle instance de la DirectoryNotFoundException classe avec sa chaîne de message définie message sur et son HRESULT défini sur COR_E_DIRECTORYNOTFOUND.

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)

Paramètres

message
String

Qui String décrit l’erreur. Le contenu de message l’objet est destiné à être compris par les humains. L’appelant de ce constructeur est requis pour s’assurer que cette chaîne a été localisée pour la culture système actuelle.

Remarques

Ce constructeur initialise la Exception.Message propriété de la nouvelle instance à l’aide messagede .

La Exception.InnerException propriété de la nouvelle instance est initialisée sur null.

Voir aussi

S’applique à

DirectoryNotFoundException(SerializationInfo, StreamingContext)

Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs

Attention

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

Initialise une nouvelle instance de la DirectoryNotFoundException classe avec les informations de sérialisation et de contexte spécifiées.

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);
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}")>]
new System.IO.DirectoryNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.IO.DirectoryNotFoundException
new System.IO.DirectoryNotFoundException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.IO.DirectoryNotFoundException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Paramètres

info
SerializationInfo

SerializationInfo Qui contient les données d’objet sérialisées sur l’exception levée.

context
StreamingContext

Qui StreamingContext contient des informations contextuelles sur la source ou la destination.

Attributs

Voir aussi

S’applique à

DirectoryNotFoundException(String, Exception)

Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs
Source:
DirectoryNotFoundException.cs

Initialise une nouvelle instance de la DirectoryNotFoundException classe avec un message d’erreur spécifié et une référence à l’exception interne qui est la cause de cette exception.

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)

Paramètres

message
String

Message d’erreur qui explique la raison de l’exception.

innerException
Exception

Exception qui est la cause de l’exception actuelle. Si le innerException paramètre n’est pas null, l’exception actuelle est levée dans un catch bloc qui gère l’exception interne.

Remarques

Une exception levée en conséquence directe d’une exception précédente doit inclure une référence à l’exception précédente dans la InnerException propriété. La InnerException propriété retourne la même valeur que celle passée dans le constructeur, ou null si la InnerException propriété ne fournit pas la valeur d’exception interne au constructeur.

Le tableau suivant présente les valeurs de propriété initiales d’une instance de DirectoryNotFoundException.

Propriété Valeur
InnerException Référence d’exception interne.
Message Chaîne de message d’erreur.

Voir aussi

S’applique à