public void AddDirStore(DirStore store) { if (children.Count < branchingFactor) { children.Add(store); string oldPath = store.GetPath(); store.parent = this; string newPath = store.GetPath(); try { Directory.Move(oldPath, newPath); } catch { // For some reason, the above throws an access violation SOMETIMES. // I think this happens when the directory was just created. // Retrying the operation here seams to eliminate all problems. Directory.Move(oldPath, newPath); } } else { if (parent == null) { throw new DirStoreFullException(); } else { DirStore prevStore = new DirStore(branchingFactor, basePath); prevStore.AddDirStore(store); parent.AddDirStore(prevStore); } } }
public string GetPath() { if (parent == null) { return(Path.Combine(basePath, name)); } return(Path.Combine(parent.GetPath(), name)); }