How to create a copy of a file that is uploaded using OpenFileDialog Box .I have to save that copy in a folder.
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog op1 = new OpenFileDialog();
op1.Multiselect = false;
op1.InitialDirectory = Application.StartupPath;
op1.ShowDialog();
op1.Filter = "allfiles|*.bin";
if (op1.ShowDialog() == DialogResult.OK)
{
string name = op1.FileName;
MessageBox.Show("FileName is", name);
System.IO.File.Copy(name, Path.Combine(Path.GetDirectoryName(name), Path.GetFileNameWithoutExtension(name) + ".bin"));
//op1.Save(Application.StartupPath + @"\Code_" + DateTime.Now.ToString("d_MM_yy_HH_mm_ss") + ".bin");
}
}

Salman BegRank #284 · 8.8K reputationPosted Mar 15, 2019, 9:24 PM EDT
Jignesh KumarRank #91 · 22.9K reputationPosted Mar 15, 2019, 10:11 PM EDT
Kip HackmanRank #2,595 · 536 reputationPosted Mar 30, 2022, 2:43 PM EDT
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Mar 30, 2022, 4:12 PM EDT