lalala
[mono.git] / mcs / class / corlib / System.IO / FileNotFoundException.cs
1 //
2 // System.IO.FileNotFoundException.cs
3 //
4 // Author:
5 //   Paolo Molaro (lupus@ximian.com)
6 //   Duncan Mak (duncan@ximian.com)
7 //
8 // (C) 2001 Ximian, Inc.  http://www.ximian.com
9 //
10 using System.Globalization;
11 using System.IO;
12 using System.Runtime.Serialization;
13
14 namespace System.IO {
15
16         [Serializable]
17         public class FileNotFoundException : IOException {
18                 private string fileName;
19                 private string fusionLog;
20
21                 // Constructors
22                 public FileNotFoundException ()
23                         : base (Locale.GetText ("File not found"))
24                 {
25                 }
26
27                 public FileNotFoundException (string message)
28                         : base (message)
29                 {
30                 }
31
32                 public FileNotFoundException (string message, Exception inner)
33                         : base (message, inner)
34                 {
35                 }
36
37                 public FileNotFoundException (string message, string fileName)
38                         : base (message)
39                 {
40                         this.fileName = fileName;
41                 }
42
43                 public FileNotFoundException (string message, string fileName, Exception innerException)
44                         : base (message, innerException)
45                 {
46                         this.fileName = fileName;
47                 }
48
49                 protected FileNotFoundException (SerializationInfo info, StreamingContext context)
50                         : base (info, context)
51                 {
52                         fileName = info.GetString ("FileNotFound_FileName");
53                         fusionLog = info.GetString ("FileNotFound_FusionLog");
54                 }
55
56                 public string FileName
57                 {
58                         get { return fileName; }
59                 }
60
61                 public string FusionLog
62                 {
63                         get { return fusionLog; }
64                 }
65
66                 public override string Message
67                 {
68                         get {
69                                 if (base.Message == null)
70                                         return "File not found";
71
72                                 if (fileName == null)
73                                         return base.Message;
74                                 
75                                 return "File '" + fileName + "' not found.";
76                         }
77                 }
78
79                 public override void GetObjectData (SerializationInfo info, StreamingContext context)
80                 {
81                         base.GetObjectData (info, context);
82                         info.AddValue ("FileNotFound_FileName", fileName);
83                         info.AddValue ("FileNotFound_FusionLog", fusionLog);
84                 }
85
86                 public override string ToString ()
87                 {
88                         string result = GetType ().FullName + ": " + Message;
89                         if (InnerException != null)
90                                 result += " ----> " + InnerException.ToString ();
91
92                         if (StackTrace != null)
93                                 result += "\n" + StackTrace;
94
95                         return result;
96                 }
97         }
98 }