コード例 #1
0
 static void _Create(string WorkName)
 {
     try {
         if (System.IO.File.Exists(WorkName + ".txt"))
         {
             Console.WriteLine("Файл существует, переписать? yes = y; no = all other char ");
             string ANS;
             ANS = Console.ReadLine();
             if (ANS.ToLower() == "y")
             {
                 System.IO.File.WriteAllText(WorkName + ".txt", "");
                 Console.WriteLine("Create successful");
             }
         }
         else
         {
             System.IO.File.WriteAllText(WorkName + ".txt", "");
             Console.WriteLine("Create successful");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("The process failed: {0}", e.ToString());
     }
 }
コード例 #2
0
 static string _Entering(string Way)
 {
     try
     {
         string BufWay;
         BufWay = System.Text.RegularExpressions.Regex.Replace(Way, @"\s+", " ").Trim() + "/";
         if (System.IO.Directory.Exists(BufWay))
         {
             return(BufWay);
         }
         else
         {
             Console.WriteLine("Каталога не существует, создать? yes = y; no = all other char ");
             string ANS;
             ANS = Console.ReadLine();
             if (ANS.ToLower() == "y")
             {
                 System.IO.Directory.CreateDirectory(BufWay);
                 return(BufWay);
             }
             else
             {
                 return("xer");
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("The process failed: {0}", e.ToString());
         return("xer");
     }
 }