Ejemplo n.º 1
0
 public bool Save(FileFormat file, string location)
 {
     if (!Initalized)
     {
         throw new Exception("You must initalized the disk hander to be able to save");
     }
     location = SetUpPath(file, location);
     try
     {
         using (Stream disk = RFile.Create(location))
         {
             DataContractSerializer writer = new DataContractSerializer(file.GetType());
             writer.WriteObject(disk, file);
         }
         return(true);
     }
     catch (Exception x)
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
        public object Load(FileFormat file, string location)
        {
            if (!Initalized)
            {
                throw new Exception("You must initalized the disk hander to be able to load");
            }

            location = SetUpPath(file, location);
            try
            {
                using (Stream disk = RFile.OpenRead(location))
                {
                    Type t = file.GetType();
                    DataContractSerializer writer = new DataContractSerializer(file.GetType());
                    return(writer.ReadObject(disk));
                }
            }
            catch
            {
                return(null);
            }
        }