public void MoveFile(string sourcePath, string destinationPath)
{
if(sourcePath == null || destinationPath == null) {
throw new ArgumentNullException("sourcePath | destionationPath");
}
string[] sourceComponents = sourcePath.Split(Separators, StringSplitOptions.RemoveEmptyEntries);
string[] destinationComponents = destinationPath.Split(Separators, StringSplitOptions.RemoveEmptyEntries);
if(sourceComponents.Length == 0 || destinationComponents.Length == 0) {
return;
}
// extract the file names
string sourceFileName = sourceComponents[sourceComponents.Length - 1];
string destinationFileName = destinationComponents[destinationComponents.Length - 1];
StoreFolder sourceFolder = GetFolder(sourcePath.Substring(0, sourcePath.Length - sourceFileName.Length));
StoreFolder destinationFolder = CreateFolderImpl(destinationPath.Substring(0, destinationPath.Length - destinationFileName.Length));
// copy to destination
if(destinationFolder.Files.ContainsKey(destinationFileName)) {
destinationFolder.Files[destinationFileName] = sourceFolder.Files[sourceFileName];
}
else {
destinationFolder.Files.Add(destinationFileName, sourceFolder.Files[sourceFileName]);
}
// remove from source
sourceFolder.Files.Remove(sourceFileName);
}