public void Save(ICarouselUser user) { string path = CarouselUserRepository.ConstructPath(this.GetActualSavePath(), user.Name); DataContractSerializer serializer = new DataContractSerializer(typeof(CarouselUserDTO)); // Creates or overwrites the file at the path given. using (FileStream fs = File.Open(path, FileMode.Create)) { serializer.WriteObject(fs, new CarouselUserDTO(user)); } }
public ICarouselUser GetByName(string name) { string path = CarouselUserRepository.ConstructPath(this.GetActualSavePath(), name); if (File.Exists(path)) { return(this.LoadFromPath(path)); } else { throw new FileNotFoundException("Unable to find the user file.", path); } }