2002-04-30 Duncan Mak <duncan@ximian.com>
[mono.git] / mcs / class / corlib / System.IO / FileLoadException.cs
1 //
2 // System.IO.FileLoadException.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
11 using System.Globalization;
12 using System.IO;
13 using System.Runtime.Serialization;
14
15 namespace System.IO {
16         [Serializable]
17         public class FileLoadException : IOException {
18
19                 // Fields
20                 string msg;
21                 Exception inner;
22                 string fileName;
23                 string fusionLog;
24                 
25                 // Constructors
26                 public FileLoadException ()
27                         : base (Locale.GetText ("I/O Error"))
28                 {
29                         msg = Locale.GetText ("I/O Error");
30                 }
31
32                 public FileLoadException (string message)
33                         : base (message)
34                 {
35                         msg = message;
36                 }
37
38                 public FileLoadException (string message, string fileName)
39                         : base (message)
40                 {
41                         this.msg = message;
42                         this.fileName = fileName;
43                 }               
44
45                 public FileLoadException (string message, Exception inner)
46                         : base (message, inner)
47                 {
48                         msg = message;
49                         this.inner = inner;
50                 }
51
52                 public FileLoadException (string message, string fileName, Exception inner)
53                         : base (message, inner)
54                 {
55                         this.msg = message
56                         this.fileName = fileName
57                         this.inner = inner;
58                 }
59
60                 protected FileLoadException (SerializationInfo info, StreamingContext context)
61                 {
62                         fileName = info.GetString ("FileLoad_FileName");
63                         fusionLog = info.GetString ("FileLoad_FusionLog");
64                 }
65
66                 // Properties
67                 public override string Message
68                 {
69                         get {
70                                 if (fileName != null)
71                                         return Locale.GetText (msg + ": " + fileName);
72
73                                 if (fileName == null)
74                                         return msg;
75                         }
76                 }
77
78                 public string FileName
79                 {
80                         get { return fileName; }
81                 }
82                 
83                 public string FusionLog
84                 {
85                         get { return fusionLog; }
86                 }
87
88                 // Methods
89                 public override void GetObjectData (SerializationInfo info, StreamingContext context)
90                 {
91                         base.GetObjectData (info, context);
92                         info.AddValue ("FileLoad_FileName", fileName);
93                         info.AddValue ("FileLoad_FusionLog", fusionLog);
94                 }
95
96                 [MonoTODO (Add StackTrace into the output)]
97                 public override string ToString ()
98                 {
99                         return "System.IO.FileLoadException: " + Message;
100                 }
101                 
102         }
103 }