Weird problem with DOS Command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akshaycjoshi
    New Member
    • Jan 2007
    • 153

    Weird problem with DOS Command

    I am developign one application where i copy one file to other location using
    System.Diagnost ics.Process.Sta rt

    In developement the command is just running fine .
    The command is

    /c copy C:\app\mainstru cture.mdb C:\traffic\traf ficmanagement\t rafficmanagemen t\bin\Debug

    /c rename C:\traffic\traf ficmanagement\t rafficmanagemen t\bin\Debug\mai nstructure.mdb 1999fine.mdb

    But when i create setup package of it and run the application it can not copy and rename the file.
    I had used the application.pat h to get a general software.

    the exact command running are

    /c copy C:\app\mainstru cture.mdb C:\Program Files\Bell Solutions\Traff icLedger


    /c rename C:\Program Files\Bell Solutions\Traff icLedger\mainst ructure.mdb 2008fine.mdb

    Even when i run these commands in Comamnd window it gives invalid syntax error.

    I can see the file infront of me and everything is ok.

    I know it's a silly question but it's realy killing me.

    Please help me guys.

    Thanks !
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    So you are really running cmd.exe and applying those strings as arguments?
    Frequently it is the case that you would need to surround the path and filenames with quotes, since they (could) have spaces in them. And be sure to end directories with a "\" otherwise how would it know you didn't want to copy the file to the name "Debug".
    Which leads me to another thing, that operation can be done in one step, no need for two.

    /c copy "C:\app\mainstr ucture.mdb" "C:\traffic\tra fficmanagement\ trafficmanageme nt\bin\Debug\19 99fine.mdb"

    Comment

    • Curtis Rutland
      Recognized Expert Specialist
      • Apr 2008
      • 3264

      #3
      But the real question is, why? Why do you need to use the shell copy command, when you have classes like FileInfo and DirectoryInfo that let you do that in managed code?

      Comment

      • akshaycjoshi
        New Member
        • Jan 2007
        • 153

        #4
        Thanks a zillion times Plater !

        BTW insertAlias i wanted to embed one blank database to my project so that at the begining of each year i will just copy the embeded blank database and rename it to current year.SO that i have a seperate database for each year.


        Guys , I cold have started a new thread but I think it's unncesary to do that so i am asking it here.

        Which is the best book for SQL server , i am a beginer and wanted to learn SQL server 2006 from scratch.

        Comment

        • Curtis Rutland
          Recognized Expert Specialist
          • Apr 2008
          • 3264

          #5
          I understand what you want to do, I'm saying that you can copy and rename files from within .NET. You don't have to use shell commands. If you look up System.IO.FileI nfo, there are methods for renaming, moving and copying, along with several other useful tools for file manipulation.

          As to the new question, that's called hijacking threads, even if they are your own. Please start a new one. But this forum is for technical QA only, so if you do start one, start it in Misc Questions.

          Thanks.

          Comment

          • akshaycjoshi
            New Member
            • Jan 2007
            • 153

            #6
            Ohh i am sorry I used those shell commands coz i dont know about .NET I/O.
            As far as highjacking is concerned , i didn't know hat either.
            Will start a new thread.

            Thanks !

            Comment

            Working...