Пример #1
0
        /* Get the filename to use for a new wallet */
        private static string GetNewWalletName()
        {
            while (true)
            {
                YellowMsg.Write(
                    "What filename would you like to give your new wallet?: "
                    );

                string filename = Console.ReadLine();

                string appended = filename + ".wallet";

                if (string.IsNullOrWhiteSpace(filename))
                {
                    RedMsg.WriteLine(
                        "Wallet name cannot be empty! Try again.\n"
                        );

                    continue;
                }

                if (GeneralUtilities.FilenameInUse(filename) ||
                    GeneralUtilities.FilenameInUse(appended))
                {
                    RedMsg.Write("A file with the name ");
                    YellowMsg.Write(filename);
                    RedMsg.Write(" or ");
                    YellowMsg.Write(appended);
                    RedMsg.WriteLine(" already exists! Try again.\n");
                }
                /* If the file already ends with .wallet, return it. */
                else if (filename.EndsWith(".wallet"))
                {
                    return(filename);
                }
                /* Else, append .wallet to the filename */
                else
                {
                    return(appended);
                }
            }
        }