I have a directory (say string pathFile = P: \ Database \ new) to which I want to copy the file selected by the user. Began to write:

private void внестиДанныеToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog opfd = new OpenFileDialog(); if (opfd.ShowDialog() == DialogResult.OK) { string path = opfd.FileName;//этот файл нужно сохранить в заданную заранее директорию //? } } 

Tell me how to modify the code so that the file is saved in the specified directory, thanks.

  • @AntonKomyshan Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (as well as comments) do not add knowledge to the Runet. - Nicolas Chabanovsky

1 answer 1

For example:

 File.Copy (path, outPath );