Error in Savedialog c#

Asked

Viewed 39 times

1

Good, I have this snippet of code in C# and everything is working, but I have an error that I haven’t been able to solve, as you can see in the image and in the code. The label1 is fetching text from a textbox, as you can see here:

I only want the "M000050" to appear for example. What is before does not matter that it appears, because it does not allow to record.

ERROR inserir a descrição da imagem aqui

CODE

 private void button1_Click(object sender, EventArgs e)
 {
        SaveFileDialog salvar = new SaveFileDialog();
        salvar.FileName = label1 + ".cnf";
        salvar.Filter = "Ficheiro de Configuração|*.cnf";
        salvar.DefaultExt = "txt";
        DialogResult salvou = salvar.ShowDialog();
        (...)
 }

1 answer

1


Alter:

salvar.FileName = label1 + ".cnf";

To:

salvar.FileName = label1.Text + ".cnf";

inserir a descrição da imagem aqui

  • 1

    No more friend, nor had I detected my little mistake. Cumps

Browser other questions tagged

You are not signed in. Login or sign up in order to post.