Example #1
0
        private string CardPath(CatalogCode code)
        {
            string testFolder = folder + storage + FolderFor(code);

            return(Directory.EnumerateFiles(testFolder)
                   .FirstOrDefault(p => Path.GetFileNameWithoutExtension(p).Contains(code.ToString())));
        }
Example #2
0
        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);
        }
Example #3
0
        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);
                    }
                }
            }
        }