Dear Experts,
Please, help me resolve an issue in Visual Studio #C.
I am creating utility for renaming of names of multiple files.
Main idea = user opens the folder with files and selects required files for renaming in listbox.
Selection can be performed via searching by special words in names of items (masks "MD").
I have completed work at filtrating names of files and changing their names in listbox. But my problem - I cannot copy name of items and save these as names of files in folder.
Have you ever been observed such problem?
Please help me in solution.
What I have tried:
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
listBox1.Items.Clear();
string[] files = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
string[] dirs = Directory.GetDirectories(folderBrowserDialog1.SelectedPath);
SelectedPathText.Text = folderBrowserDialog1.SelectedPath;
foreach (string file in files)
{
listBox1.Items.Add(Path.GetFileName(file));
}
foreach (string dir in dirs)
{
listBox1.Items.Add(Path.GetFileName(dir));
SelectedPathText.Text = Path.GetFileName(dir);
}
}
}
private void button3_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
DialogResult result = MessageBox.Show("Are you sure ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
{
timer1.Enabled = true;
try
{
if (checkBox1.Checked)
{
int SelectedItem = listBox1.SelectedIndex;
listBox1.Items.RemoveAt(SelectedItem);
listBox1.Items.Insert(SelectedItem, (textBox_rig.Text + ("_" + (textBox_field.Text + ("_" + (textBox_pad.Text + ("_" + (textBox_well.Text + ("_" + (comboBox1.Text +("_" +("_"+ (comboBox2.Text + ("_" + ("MD"+ ("_"+ (textBox_start.Text + ("-" + (textBox_end.Text + (".PDF"))))))))))))))))))));
}
}
catch
{
Application.DoEvents();
}
}
}