Example #1
0
        public static string fileName(string path, string name)
        {
            string[] files = Directory.GetFiles(path);

            uc_fullFileName ffn;
            for(int i = 0; i < files.Length; i++)
            {
                ffn = new uc_fullFileName(files[i]);
                files[i] = ffn.File + ffn.Extension;
            }

            uc_fileName fn = new uc_fileName(name);
            string fn_name = fn.Name;
            int cnt = 0;
            bool finish = false;

            while (finish != true)
            {
                finish = true;
                foreach (string fname in files)
                {
                    if (fname.ToUpper() == fn.ToString().ToUpper())
                    {
                        finish = false;
                        fn.setName(fn_name + Convert.ToString(++cnt) + fn.Extension);
                        break;
                    }
                }
            }

            return fn.ToString();
        }
Example #2
0
        static void Main(string[] args)
        {
            uc_fullFileName fn = new uc_fullFileName(Directory.GetCurrentDirectory() + "test.exe");
            Console.WriteLine("Full path: {0} \n",fn);
            Console.WriteLine("Directory: {0}", fn.Directory);
            Console.WriteLine("File name: {0}", fn.File);
            Console.WriteLine("Extension: {0}",fn.Extension);
            uc_fileName fname = new uc_fileName("Test.txt");

            Console.WriteLine(check.fileName(@"D:\test\", "1.txt"));

            Console.ReadLine();
        }