public bool Load(string path)
{
if(path == null) {
throw new ArgumentNullException("path");
}
// check if the file exists
if(File.Exists(path) == false) {
return false;
}
FileStream reader = null;
try {
reader = new FileStream(path, FileMode.Open);
if(reader.CanRead) {
BinaryFormatter formatter = new BinaryFormatter();
StoreData data = (StoreData)formatter.Deserialize(reader);
files = data.Files;
_encrypt = data.Encrypted;
_useDPAPI = data.UseDPAPI;
DeserializeFolders(data.RootFolder);
return true;
}
}
catch(Exception e) {
Debug.ReportError("Failed to deserialize store. Path: {0}, Exception: {1}", path, e.Message);
return false;
}
finally {
if(reader != null) {
reader.Close();
}
}
return true;
}