FileLoadException.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // System.IO.FileLoadException.cs
  3. //
  4. // Author:
  5. // Paolo Molaro ([email protected])
  6. // Duncan Mak ([email protected])
  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. namespace System.IO {
  14. [Serializable]
  15. public class FileLoadException : IOException {
  16. // Fields
  17. string msg;
  18. Exception inner;
  19. string fileName;
  20. string fusionLog;
  21. // Constructors
  22. public FileLoadException ()
  23. : base (Locale.GetText ("I/O Error"))
  24. {
  25. msg = Locale.GetText ("I/O Error");
  26. }
  27. public FileLoadException (string message)
  28. : base (message)
  29. {
  30. msg = message;
  31. }
  32. public FileLoadException (string message, string fileName)
  33. : base (message)
  34. {
  35. this.msg = message;
  36. this.fileName = fileName;
  37. }
  38. public FileLoadException (string message, Exception inner)
  39. : base (message, inner)
  40. {
  41. msg = message;
  42. this.inner = inner;
  43. }
  44. public FileLoadException (string message, string fileName, Exception inner)
  45. : base (message, inner)
  46. {
  47. this.msg = message;
  48. this.fileName = fileName;
  49. this.inner = inner;
  50. }
  51. protected FileLoadException (SerializationInfo info, StreamingContext context)
  52. {
  53. fileName = info.GetString ("FileLoad_FileName");
  54. fusionLog = info.GetString ("FileLoad_FusionLog");
  55. }
  56. // Properties
  57. public override string Message
  58. {
  59. get {
  60. if (fileName != null)
  61. return Locale.GetText (msg + ": " + fileName);
  62. else
  63. return msg;
  64. }
  65. }
  66. public string FileName
  67. {
  68. get { return fileName; }
  69. }
  70. public string FusionLog
  71. {
  72. get { return fusionLog; }
  73. }
  74. // Methods
  75. public override void GetObjectData (SerializationInfo info, StreamingContext context)
  76. {
  77. base.GetObjectData (info, context);
  78. info.AddValue ("FileLoad_FileName", fileName);
  79. info.AddValue ("FileLoad_FusionLog", fusionLog);
  80. }
  81. public override string ToString ()
  82. {
  83. string result = GetType ().FullName + ": " + Message;
  84. if (this.InnerException != null)
  85. result +=" ----> " + InnerException;
  86. if (this.StackTrace != null)
  87. result += '\n' + StackTrace;
  88. return result;
  89. }
  90. }
  91. }