Reputation: 1073
I open file as:
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "JPG|*.jpg;*.jpeg|PNG|BMP|*.bmp|GIF|*.gif|*.png|TIFF|*.tif;*.tiff";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
//
}
How can I save immediately this file in disc? I tried:
File.Copy(openFileDialog.FileName, @"C:\");
Upvotes: 1
Views: 2112
Reputation: 182
You need to give File.Copy()
the absolute path, including the name of the file it's saving.
"C:\"
is not a valid file name, so it can't save it.
Try something like:
string fName = "myPhoto";
File.Copy(openFileDialog.FileName, @"C:\" + fName + ".jpg");
Source: MSDN
PaulF also mentioned this in the comments prior to my posting this answer.
Upvotes: 1