The Labs \ Source Viewer \ SSCLI \ System.IO \ IOException

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. /*============================================================
  16. **
  17. ** Class:  IOException
  18. **
  19. **
  20. ** Purpose: Exception for a generic IO error.
  21. **
  22. **
  23. ===========================================================*/
  24. using System;
  25. using System.Runtime.Serialization;
  26. namespace System.IO
  27. {
  28.    
  29.     [Serializable()]
  30.     [System.Runtime.InteropServices.ComVisible(true)]
  31.     public class IOException : SystemException
  32.     {
  33.         // For debugging purposes, store the complete path in the IOException
  34.         // if possible. Don't give it back to users due to security concerns.
  35.         // Let the code that throws the exception worry about that. But we can
  36.         // at least assist people attached to the process with a managed
  37.         // debugger. Don't serialize it to avoid any security problems.
  38.         // This information isn't guaranteed to be correct, but is our second
  39.         // best effort at a file or directory involved, after the exception
  40.         // message.
  41.         [NonSerialized()]
  42.         private string _maybeFullPath;
  43.         // For debuggers on partial trust code
  44.         public IOException() : base(Environment.GetResourceString("Arg_IOException"))
  45.         {
  46.             SetErrorCode(__HResults.COR_E_IO);
  47.         }
  48.        
  49.         public IOException(string message) : base(message)
  50.         {
  51.             SetErrorCode(__HResults.COR_E_IO);
  52.         }
  53.        
  54.         public IOException(string message, int hresult) : base(message)
  55.         {
  56.             SetErrorCode(hresult);
  57.         }
  58.        
  59.         // Adding this for debuggers when looking at exceptions in partial
  60.         // trust code that may not have interesting path information in
  61.         // the exception message.
  62.         internal IOException(string message, int hresult, string maybeFullPath) : base(message)
  63.         {
  64.             SetErrorCode(hresult);
  65.             _maybeFullPath = maybeFullPath;
  66.         }
  67.        
  68.         public IOException(string message, Exception innerException) : base(message, innerException)
  69.         {
  70.             SetErrorCode(__HResults.COR_E_IO);
  71.         }
  72.        
  73.         protected IOException(SerializationInfo info, StreamingContext context) : base(info, context)
  74.         {
  75.         }
  76.     }
  77. }

Developer Fusion