public void HardDelete(FSViewTree.FileNode target) { // Perminant deletion, I want to make one that if (target.thisFile.Exists) { target.thisFile.Delete(); } return; }
public void Copy(FSViewTree.FileNode source, FSViewTree.DirNode dest) { // Copy source file into destination directory // If file name exists, increment until no conflict. if (source.thisFile.Exists) { // Use Linq? string destName = source.thisFile.Name; int periodIndex = destName.LastIndexOf('.'); // TODO: Check if periodIndex is -1 and change the logic appropriately string namePrefix = destName.Substring(0, periodIndex); string nameSuffix = destName.Substring(periodIndex + 1); var FolderHits = from dir in dest.folders where NameTest(namePrefix, nameSuffix, dir.thisDir.Name) select dir; var FileHits = from file in dest.files where NameTest(namePrefix, nameSuffix, file.thisFile.Name) select file; int totalHits = FolderHits.Count() + FileHits.Count(); string finalName = ""; if (totalHits > 0) { finalName = namePrefix + $" {totalHits}." + nameSuffix; } else { finalName = destName; } string sourceName = source.thisFile.Name; source.thisFile.CopyTo(dest.path + "/" + finalName); } bool NameTest(string prefix, string suffix, string testName) { int periodIndex = testName.LastIndexOf('.'); string testPrefix = String.Empty; string testSuffix = String.Empty; if (periodIndex == -1) { testPrefix = testName.Substring(0); } else { testPrefix = testName.Substring(0, periodIndex); testSuffix = testName.Substring(periodIndex + 1); } return(prefix.Equals(testPrefix) && suffix.Equals(testSuffix)); } }
public void Rename(FSViewTree.FileNode target, string name) { }