// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//============================================================
//
// Class: FileNotFoundException
//
// Purpose: Exception for accessing a file that doesn't exist.
//
//===========================================================
using System;
namespace System.IO
{
// Thrown when trying to access a file that doesn't exist on disk.
//|
public class FileNotFoundException : IOException {
private String _fileName; // The name of the file that isn't found.
//|
public FileNotFoundException()
: base("IO.FileNotFound") {
}
//|
public FileNotFoundException(String message)
: base(message) {
}
//|
public FileNotFoundException(String message, Exception innerException)
: base(message, innerException) {
}
//|
public FileNotFoundException(String message, String fileName) : base(message)
{
_fileName = fileName;
}
//|
public FileNotFoundException(String message, String fileName, Exception innerException)
: base(message, innerException) {
_fileName = fileName;
}
//|
public override String Message
{
get {
String message = base.Message;
if (message == null) {
if (_fileName == null)
return "IO.FileNotFound";
else
return "IO.FileNotFound" + _fileName;
}
else {
return message;
}
}
}
//|
public String FileName {
get { return _fileName; }
}
//|
public override String ToString()
{
String s = GetType().FullName + ": " + Message;
if (_fileName != null && _fileName.Length != 0)
s += Environment.NewLine + String.Format("IO.FileName_Name", _fileName);
if (InnerException != null)
s = s + " ---> " + InnerException.ToString();
return s;
}
}
}