3
The program I’m creating should take the following steps:
First the user creates a subfolder to go saving the projects that were calculated by the program, as image and code below.
When the user creates a subfolder, for example "Em01_project of a block 4", it is created within a predefined directory (c: Vandro Tad "Em01_project of a block 4")
How do I save a file where the name already fixed in the code written in C# "Loads.txt" where when the user clicks on the "Save" button, as shown below, and this command recognizes the path of the subfolder opened or created through the textBox_NomeBloco.Text by the end user as explained in item 2?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Tad_Bloco1._0
{
public partial class NovoBloco : 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;
}
}
}
Explain it better, at least for me the question is not making sense.
– Daniel Dutra
Good evening Daniel How do I create a code to save a file where the name is already fixed in the code written in C# "Loads.txt" where when the user clicks on the "Save" button, this command recognizes the path of the folder opened or created by the end user as explained in item 2.
– Evandro Mendes
In the method
button_Ok_Click
you save the last folder creates in thelistBox_ListaBlocos
, right? If so, the last record of thisListBox
is the last folder created:listBox_ListaBlocos.Items[listBox_ListaBlocos.Items.Count - 1];
– Daniel Dutra
That’s right Daniel
– Evandro Mendes
Was that the only problem? Has your problem been solved then? The save part
txt
you got?– Daniel Dutra
Sorry Daniel actually the listbox is just for the user to view which and how many folders he has. The last folder is in the textBox_NomeBloco
– Evandro Mendes
In fact
textBox_NomeBloco.Text
has the folder selected inListBox
, no? Anyway, if your problem has already been solved, delete the question, because it is not very good.– Daniel Dutra
Daniel I rephrased the question, maybe I believe it should be clearer!
– Evandro Mendes
Really, I could understand well what your program should do, but now you are not speaking your question. What is your question? How hard are you to do what you listed up there?
– Daniel Dutra
The code upstairs is okay. My question is how to create a code in the second Forms (the second image) where when I click the "save" button, this recognizes the subfolder that was created by the user in the textBox_NomeBloco.Text and saves the fixed file "Load.txt".
– Evandro Mendes
Honestly I think you don’t have a doubt, you want someone here to do your job for you. I recommend studying a little
c#
andWindows Forms
, is full of tutorial on the internet for this: http://bfy.tw/6ICZ– Daniel Dutra
Return PHP array in JSON in AJAX
– Alisson Hoepers
As I said before, I am not a programmer but a civil engineer, I am only developing this program for personal use. Thank you very much!
– Evandro Mendes
@Evandromendes It’s okay that you’re not a programmer, but even so, do a better search on the subject that you have questions about,.
– Falion