Esempio n. 1
0
        private void restoreName(String path, VFolder actFolder)
        {
            System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(path);

            foreach (VFolder act in actFolder.SubFolders)
            {
                System.IO.Directory.Move(path + "\\" + act.NewName, path + "\\" + act.Name);
                restoreName(path + "\\" + act.Name, act);
                progressBar1.PerformStep();
            }
        }
Esempio n. 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            progressBar1.Value   = 0;
            progressBar1.Maximum = System.IO.Directory.GetDirectories(textBox1.Text, "*", System.IO.SearchOption.AllDirectories).Count();
            progressBar1.Minimum = 0;
            progressBar1.Step    = 1;

            VFolder        root = renameContent(textBox1.Text);
            SaveFileDialog dg   = new SaveFileDialog();

            dg.FileName         = "Names.xml";
            dg.Filter           = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
            dg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            if (dg.ShowDialog() == DialogResult.OK)
            {
                System.IO.TextWriter writer = new System.IO.StreamWriter(dg.FileName);
                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(root.GetType());
                x.Serialize(writer, root);
                writer.Close();
                MessageBox.Show("All directories renamed", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 3
0
        private VFolder renameContent(String path)
        {
            System.IO.DirectoryInfo   directory   = new System.IO.DirectoryInfo(path);
            System.IO.DirectoryInfo[] directories = directory.GetDirectories();
            VFolder actFolder = new VFolder();

            actFolder.Name = directory.Name;

            String  newName;
            VFolder temp;

            foreach (System.IO.DirectoryInfo folder in directories)
            {
                newName      = generateName();
                temp         = renameContent(folder.FullName);
                temp.NewName = newName;
                actFolder.SubFolders.Add(temp);
                System.IO.Directory.Move(folder.FullName, folder.Parent.FullName + "\\" + newName);
                progressBar1.PerformStep();
            }

            return(actFolder);
        }