Skip to content

Copying file error.

asma

Asked Jun 23, 2008, 4:31 AM EDT4 answers
Share
LinkedInX
Hi m trying to copy image file from one location to other as below in openDialog box C#.net
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
            string filename = System.IO.Path.GetFileName(openFileDialog1.FileName);

          string fname = Application.StartupPath + "\\Temp\\" + filename;
                File.Copy(openFileDialog1.FileName, fname, true);
}


I get Exception as
   Unknown software  Exception(0xe0434f4d) ocurred in application at location 0x7c59bcb1
It works for all files except for .bmp file
Ne help for it?

    

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    try to use

    File.Copy(filename, fname, true)

    File.copy syntax is File.Copy (string source_path, string destination_path, bool overwrite)

    0
  • 0
    Hi
      I tried by changing the code...but the exception still occurs
    0
  • 0

    OK,  your code should look like this:

    Code
    if (openFileDialog1.ShowDialog() == DialogResult.OK)
    {
    
    string filename = System.IO.Path.GetFileName(openFileDialog1.FileName);
    string fname = Application.StartupPath + "\\" + filename;
    
    File.Copy (openFileDialog1.FileName.ToString(), fname, true);
    }

    Now it should work (works for me).

    0
  • 1 short reply
    • 0
      No it doesnt work for me.....
      0