private string CardPath(CatalogCode code) { string testFolder = folder + storage + FolderFor(code); return(Directory.EnumerateFiles(testFolder) .FirstOrDefault(p => Path.GetFileNameWithoutExtension(p).Contains(code.ToString()))); }
private void SetFileCode(string originalFile, CatalogCode code, string title) { string name = $"{code.ToString()} {title}"; string path = folder + storage + FolderFor(code) + "\\" + name + Path.GetExtension(originalFile); string temppath = Directory.EnumerateFiles(Path.GetDirectoryName(path)) .FirstOrDefault(o => Path.GetFileNameWithoutExtension(o) == name); if (temppath != null) { File.Delete(temppath); } File.Move(originalFile, path); }
private void PromptDeleteFile() { PC.FormatWriteLine("Insert the code to {-3}", "delete"); CatalogCode code = new CatalogCode(ReadAnswer()); if (IsFile(code)) { YNAnswer response = AskYNQuestion($"Are you sure you want to delete {catalog.Get(code).FancifyEntry()}?"); if (response == YNAnswer.Yes) { string path = Directory.EnumerateFiles(folder + storage + FolderFor(code)) .FirstOrDefault(s => s.Contains(code.ToString())); if (path != default) { File.Delete(path); } } } }