Reputation: 11
I'm getting the error "Extensions" is a folder, not a file, when trying to run this
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "MSL Files (.MSL)|*.MSL";
var onlyFileName = System.IO.Path.GetFileName(openFileDialog.FileName);
bool flag = openFileDialog.ShowDialog() == DialogResult.OK;
if (flag)
{
this.txtPath.Text = openFileDialog.FileName;
File.Copy(txtPath.Text, Application.StartupPath + @"\Extensions\" + @onlyFileName);
}
extensionTree.Refresh();
How to fix?
Upvotes: 0
Views: 212
Reputation: 2917
You set onlyFileName before you show the dialog, which means it is null (empty) so it doesn't get added on to your path.
Upvotes: 1