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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. Using WScript.Shell to copy a file on the server.

Using WScript.Shell to copy a file on the server.

Scheduled Pinned Locked Moved Web Development
csharpasp-netsysadminlinuxhelp
6 Posts 3 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.
  • C Offline
    C Offline
    chubbysilk
    wrote on last edited by
    #1

    Hello, I would like to copy a particular file from one place on the server to another in an ASP.NET code behind page using c#. I know it can be done using vbscript with something similar to the following code: SET oShell = Server.CreateObject( "WScript.Shell" ) cmd = "cmd.exe /c copy " & originalPath & " " & destinationPath rval = oShell.Run (cmd,0,TRUE) SET oShell = Nothing I don't actually know what WScript is or does (haven't found a lot of documentation on it). When I try similar code in c#, it says I'm missing a directive. Does anyone know how to use WScript.Shell with c#? Or, is there a better way to accomplish this with out using WScript.Shell at all? Thanks for your help, RC

    P 1 Reply Last reply
    0
    • C chubbysilk

      Hello, I would like to copy a particular file from one place on the server to another in an ASP.NET code behind page using c#. I know it can be done using vbscript with something similar to the following code: SET oShell = Server.CreateObject( "WScript.Shell" ) cmd = "cmd.exe /c copy " & originalPath & " " & destinationPath rval = oShell.Run (cmd,0,TRUE) SET oShell = Nothing I don't actually know what WScript is or does (haven't found a lot of documentation on it). When I try similar code in c#, it says I'm missing a directive. Does anyone know how to use WScript.Shell with c#? Or, is there a better way to accomplish this with out using WScript.Shell at all? Thanks for your help, RC

      P Offline
      P Offline
      Paul Watson
      wrote on last edited by
      #2

      Why do you even want to use WScript? Just use the classes in System.IO. You can copy, create, delete, move etc. files and folders. regards, Paul Watson Bluegrass South Africa Anna-Jayne Metcalfe wrote: "Cynicism has it's place in life - but it should be kept well away from your inner self." Crikey! ain't life grand?

      C 1 Reply Last reply
      0
      • P Paul Watson

        Why do you even want to use WScript? Just use the classes in System.IO. You can copy, create, delete, move etc. files and folders. regards, Paul Watson Bluegrass South Africa Anna-Jayne Metcalfe wrote: "Cynicism has it's place in life - but it should be kept well away from your inner self." Crikey! ain't life grand?

        C Offline
        C Offline
        chubbysilk
        wrote on last edited by
        #3

        Hi, I'm still rather new to .NET so I didn't know that System.IO had all of these functions. I tried System.IO.Directory.Move(file1,file2) and it worked like a charm. Thanks for your help!! RC

        P 1 Reply Last reply
        0
        • C chubbysilk

          Hi, I'm still rather new to .NET so I didn't know that System.IO had all of these functions. I tried System.IO.Directory.Move(file1,file2) and it worked like a charm. Thanks for your help!! RC

          P Offline
          P Offline
          Paul Watson
          wrote on last edited by
          #4

          Cool chubbysilk, glad I could help. Another tip is to put a Using System.IO; at the top of your CS file and then you can just use Directory.Move(file1,file2); without the namespace reference. regards, Paul Watson Bluegrass South Africa Anna-Jayne Metcalfe wrote: "Cynicism has it's place in life - but it should be kept well away from your inner self." Crikey! ain't life grand?

          C T 2 Replies Last reply
          0
          • P Paul Watson

            Cool chubbysilk, glad I could help. Another tip is to put a Using System.IO; at the top of your CS file and then you can just use Directory.Move(file1,file2); without the namespace reference. regards, Paul Watson Bluegrass South Africa Anna-Jayne Metcalfe wrote: "Cynicism has it's place in life - but it should be kept well away from your inner self." Crikey! ain't life grand?

            C Offline
            C Offline
            chubbysilk
            wrote on last edited by
            #5

            Hi, I just ran into one small problem. The System.IO.Directory.Move function works when I copy a file from one folder to another on a single drive. But I am unable to copy a file from the C drive to the E drive. Do you know how to get around that? Thanks again, RC

            1 Reply Last reply
            0
            • P Paul Watson

              Cool chubbysilk, glad I could help. Another tip is to put a Using System.IO; at the top of your CS file and then you can just use Directory.Move(file1,file2); without the namespace reference. regards, Paul Watson Bluegrass South Africa Anna-Jayne Metcalfe wrote: "Cynicism has it's place in life - but it should be kept well away from your inner self." Crikey! ain't life grand?

              T Offline
              T Offline
              test2323
              wrote on last edited by
              #6

              THis is test Reply

              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