Sara Jacob

Sara Jacob

  • NA
  • 40
  • 3.1k

Creating copy of uploaded file

Mar 16 2019 12:19 AM
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");
}
}
 

Answers (4)