I would like to know how do I get all the content that was passed to a DataGridView and save it to an Excel file. So far I have this:
private void btnDiretorio_Click(object sender, EventArgs e)
{
folderBrowserDialog.RootFolder = Environment.SpecialFolder.DesktopDirectory;
folderBrowserDialog.SelectedPath = openFileDialog.InitialDirectory;
folderBrowserDialog.ShowNewFolderButton = true;
DialogResult result = folderBrowserDialog.ShowDialog();
if (result == DialogResult.OK)
{
List<string> selectedPath = listaArquivos(folderBrowserDialog.SelectedPath);
foreach (string s in selectedPath)
{
grvShowFile.Rows.Add(Path.GetFileName(s), s);
}
}
}
This code is a button that selects all files in a directory and its subfolders. Note that the DataGridView is being filled in normally.
private void btnPesquisar_Click(object sender, EventArgs e)
{
if (this.cboParametro.Text == "" || this.cboParametro.Text == "Ola"){
MessageBox.Show("Parametro inválido, por favor tente novamente.");
}
string[] arrayParam = { "FROM", "SELECT", "WHERE", "UPDATE", "" };
//Dictionary<string, string> getParam = new Dictionary<string, string>();
//getParam.Add("FROM", "WHERE");
//getParam.Add("SELECT", "Private");
StreamReader DirectorySR = new StreamReader(folderBrowserDialog.SelectedPath);
while (!DirectorySR.EndOfStream)
{
string read = DirectorySR.ReadToEnd();
DirectorySR.Close();
}
}
This is where I'm getting lost, this button needs to receive a parameter that will be passed by the user (OK!) and then load the files that were passed in the DataGridView (That's where I can not continue) and read file by file passing that array that was created with the specific words.
I am a beginner in C # and can not continue this part.