A
A
azatkafizov2020-01-10 10:19:18
C++ / C#
azatkafizov, 2020-01-10 10:19:18

WITH#. You need to select a folder so that the program subsequently processes all the files available there, how can it be implemented?

The task is to open a dialog box, select a folder and then the program processes certain files in it. I solved this problem in this way:

private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            //FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
            //DialogResult result = folderBrowserDialog1.ShowDialog();
            using (var folderBrowserDialog1 = new FolderBrowserDialog())
            {
                //folderBrowserDialog1.Filter = "Png Files (*.png)|*.png";
                //fldrDlg.Filter = "Excel Files (*.xls, *.xlsx)|*.xls;*.xlsx|CSV Files (*.csv)|*.csv
                List<string> a = new List<string>();
                if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                {

                    Directory.GetFiles(folderBrowserDialog1.SelectedPath, "ALARMHST*.txt", SearchOption.AllDirectories).ToList().ForEach(f => a.Add(f));
                    //Directory.GetFiles(folderBrowserDialog1.SelectedPath).ToList().ForEach(f => a.Add(f));
                }

Next comes the code for processing files.
The question is the following. How can I implement the function of remembering the last path to the folder, that is, so that when I press it again, it would already offer me the folder that I previously selected, otherwise it is very inconvenient to constantly re-climb and look for the desired folder. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-01-10
@azatkafizov

https://docs.microsoft.com/ru-ru/dotnet/api/system...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question