The program I'm creating should take the following steps:
First, the user creates a subfolder to save the projects that have been calculated by the program, according to the image and code below.
When you create a subfolder, for example "EM01_Project of a block 4", it is created within a predefined directory (c: \ evandro \ tad \ "EM01_Project of a block 4")
How do I save a file where the name already set in the code written in C # "Loads.txt" where when the user clicks the "Save" button, as shown below, this command recognizes the path of the subfolder opened or created through the textBox_BootName.Text by the end user as explained in item 2?
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.IO;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespaceTad_Bloco1._0{publicpartialclassNovoBloco:Form{string[]listapasta=Directory.GetDirectories(@"c:\evandro\tad");
public NovoBloco()
{
InitializeComponent();
}
private void NovoBloco_Load(object sender, EventArgs e)
{
foreach (string p in listapasta)
listBox_ListaBlocos.Items.Add(Path.GetFileName(p));
}
private void button_Ok_Click(object sender, EventArgs e)
{
string pasta = @"c:\evandro\Tad\" + textBox_NomeBloco.Text;
if (Directory.Exists(pasta) == false)
{
Directory.CreateDirectory(pasta);
listBox_ListaBlocos.Items.Add(Path.GetFileName(pasta));
MessageBox.Show("Pasta criada com sucesso!");
}
else
MessageBox.Show("Esta pasta já existe");
}
private void button_Cancelar_Click(object sender, EventArgs e)
{
this.Close();
}
private void listBox_ListaBlocos_SelectedIndexChanged(object sender, EventArgs e)
{
textBox_NomeBloco.Text = listBox_ListaBlocos.Text;
}
}
}