Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Copying file error.

Copying file error.

Scheduled Pinned Locked Moved C#
csharphelpquestion
12 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    asma_panjabi
    wrote on last edited by
    #1

    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?

    B A L S L 6 Replies Last reply
    0
    • A asma_panjabi

      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?

      B Offline
      B Offline
      Bert delaVega
      wrote on last edited by
      #2

      You should trap the exception in a Try Catch block and see what the actual error is. That exception's generic and it could be anything.

      A 1 Reply Last reply
      0
      • A asma_panjabi

        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?

        A Offline
        A Offline
        Alan Balkany
        wrote on last edited by
        #3

        I don't see anything obviously wrong, so the next step should be to get more information about the bug. See what the values are for OpenFileDialog.FileName and fname. If they look ok, put a try/catch around this, and display the message on the exception.

        A 1 Reply Last reply
        0
        • A asma_panjabi

          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?

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, did you bother looking at the values of filename and fname? IIRC OpenFileDialog.FileName returns a file path, so your fname would be garbage. FYI: (sub)folders of a StartupPath may be write-protected. You should consider using Environment.GetFolderPath() :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          Voting for dummies? No thanks. X|


          A 1 Reply Last reply
          0
          • B Bert delaVega

            You should trap the exception in a Try Catch block and see what the actual error is. That exception's generic and it could be anything.

            A Offline
            A Offline
            asma_panjabi
            wrote on last edited by
            #5

            I have trapped the exception in try catch block.

            A 1 Reply Last reply
            0
            • A Alan Balkany

              I don't see anything obviously wrong, so the next step should be to get more information about the bug. See what the values are for OpenFileDialog.FileName and fname. If they look ok, put a try/catch around this, and display the message on the exception.

              A Offline
              A Offline
              asma_panjabi
              wrote on last edited by
              #6

              I have debugged the code i get proper values in filename and fname

              1 Reply Last reply
              0
              • L Luc Pattyn

                Hi, did you bother looking at the values of filename and fname? IIRC OpenFileDialog.FileName returns a file path, so your fname would be garbage. FYI: (sub)folders of a StartupPath may be write-protected. You should consider using Environment.GetFolderPath() :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                Voting for dummies? No thanks. X|


                A Offline
                A Offline
                asma_panjabi
                wrote on last edited by
                #7

                I have debugged the code i get proper values in filename and fname. Folders and file have all permissions

                1 Reply Last reply
                0
                • A asma_panjabi

                  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?

                  S Offline
                  S Offline
                  Spacix One
                  wrote on last edited by
                  #8

                  More of a FYI than an answer , but you should always put the checked for value first:

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

                  that way if you mess up and only type one = you'll get an error during compile. This show what I mean:

                  int num = 3;
                  if (num = 4)
                  {
                  //num will be equal to 4 and this block always executes
                  }

                  vs

                  int num = 3;
                  if (4 = num)
                  {
                  //You could never build this file without an error because you can't assign to an int value
                  }


                  -Spacix All your skynet questions[^] belong to solved


                  I dislike the black-and-white voting system on questions/answers. X|


                  1 Reply Last reply
                  0
                  • A asma_panjabi

                    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?

                    L Offline
                    L Offline
                    leppie
                    wrote on last edited by
                    #9

                    asma_panjabi wrote:

                    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?

                    And if you try another .bmp, same effect? Maybe the BMP is malformed or something. Does the Temp directory exists?

                    xacc.ide - now with TabsToSpaces support
                    IronScheme - 1.0 alpha 4a out now (29 May 2008)

                    A 1 Reply Last reply
                    0
                    • A asma_panjabi

                      I have trapped the exception in try catch block.

                      A Offline
                      A Offline
                      Alan Balkany
                      wrote on last edited by
                      #10

                      The exception has a Message member. What is the message when you get this exception?

                      1 Reply Last reply
                      0
                      • L leppie

                        asma_panjabi wrote:

                        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?

                        And if you try another .bmp, same effect? Maybe the BMP is malformed or something. Does the Temp directory exists?

                        xacc.ide - now with TabsToSpaces support
                        IronScheme - 1.0 alpha 4a out now (29 May 2008)

                        A Offline
                        A Offline
                        asma_panjabi
                        wrote on last edited by
                        #11

                        Other bmp files work properly even the temp folder exists only some bmp files dnt work

                        1 Reply Last reply
                        0
                        • A asma_panjabi

                          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?

                          A Offline
                          A Offline
                          asma_panjabi
                          wrote on last edited by
                          #12

                          This is the error m getting System.UnauthorizedAccessException: Access to the path "C:\Documents and Settings\abc\Desktop\Debug\Temp\mani.bmp" is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite) at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups