Ejemplo n.º 1
0
 public AmfFile(string path)
     : base(AmfTypes.Array)
 {
     FilePath = path;
     Name = Path.GetFileNameWithoutExtension(FilePath);
     Date = File.GetLastWriteTime(path);
     try
     {
         using (var stream = File.OpenRead(path))
         {
             using (var reader = new AmfReader(stream))
             {
                 string name;
                 SerializationFormat format;
                 reader.Run(this, out name, out format);
                 Format = format;
                 Name = name;
             }
         }
     }
     // All exceptions need to be handled as the general case, since corrupt
     // saves can also cause exceptions (e.g. InvalidCastException), however,
     // we will flag permission and IO issues for consumers like FileManager
     catch (Exception e)
     {
         AmfFileError.Error type = AmfFileError.Error.Unknown;
         if (e is SecurityException || e is UnauthorizedAccessException) type = AmfFileError.Error.NoPermission;
         else if (e is IOException) type = AmfFileError.Error.Unreadable;
         Error = new AmfFileError(type, e.ToString());
     }
 }
Ejemplo n.º 2
0
 public AmfFile(string path)
     : base(AmfTypes.Array)
 {
     FilePath = path;
     Name     = Path.GetFileNameWithoutExtension(FilePath);
     Date     = File.GetLastWriteTime(path);
     try
     {
         using (var stream = File.OpenRead(path))
         {
             using (var reader = new AmfReader(stream))
             {
                 reader.Run(this, out string name, out SerializationFormat format);
                 Format = format;
                 Name   = name;
             }
         }
     }
     // All exceptions need to be handled as the general case, since corrupt
     // saves can also cause exceptions (e.g. InvalidCastException), however,
     // we will flag permission and IO issues for consumers like FileManager
     catch (Exception e)
     {
         AmfFileError.Error type = AmfFileError.Error.Unknown;
         if (e is SecurityException || e is UnauthorizedAccessException)
         {
             type = AmfFileError.Error.NoPermission;
         }
         else if (e is IOException)
         {
             type = AmfFileError.Error.Unreadable;
         }
         Error = new AmfFileError(type, e.ToString());
     }
 }