Re: Copying files using process class in ASP.NET

From: Scott Allen (bitmask_at_[nospam)
Date: 07/16/04


Date: Thu, 15 Jul 2004 23:50:17 -0400

Hi Mark,

If the problem is permissions (and like you I'd suspect this also),
you won't get an exception. Instead, the process is probably
displaying an error message in the output stream.

Use the StartInfo property to setup StandardOutput and StandardError
for reading from your code:

Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.RedirectStandardError = true;

Start the process then wait for the process to finish:

p.WaitForExit();

Then read the streams and look at what appears. Hopefully you'll find
an access denied message with some additional information.

If you need help tracking down who is getting an access denied message
on what, enable auditing and watch the security log:

http://www.pluralsight.com/keith/book/html/howto_auditfileaccess.html

HTH,

--
Scott
http://www.OdeToCode.com
On Fri, 16 Jul 2004 15:11:36 +1200, "Mark"
<markjones@n0Sp8mTAIRAWHITIdotAC.NZ> wrote:
>Hi all, I am trying to execute a batch file to copy over files from one
>server to another. The batch file is using robocopy to copy over the files.
>============
>private void CopyFiles()
>{// Use the process name space to copy over the files
>System.Diagnostics.Process oProc = new System.Diagnostics.Process();
>
>oProc.StartInfo.FileName ="c:\CopyFiles.bat" ;
>
>oProc.Start();
>
>}
>
>============
>When I run the above routine nothing gets copied and I get no error message
>whatsoever.
>When I manually run the batch file the copy works fine so it is not the
>batch file.
>
>Batch file is shown below..
>
>
>robocopy c:\images \\remoteserver\c$\images /e
>robocopy c:\documents \\remoteserver\c$\documents /e
>
>I am assumming that it might be something to do with user permission
>settings, ASPNET user has full rights on both the local machine as well as
>the remote machine.
>
>Any help appreciated.
>
>Thanks in advance
>Mark
>
>
>
>
>


Relevant Pages

  • Re: Copy shortcut to desktop in a batch file
    ... Thank you very much for your prompt response and suggestions. ... Furthermore, to make your batch file robust, add the full path ... The error message said "file not found". ... the shortcut was not copied to the desktop. ...
    (microsoft.public.windowsxp.general)
  • Re: Copy shortcut to desktop in a batch file
    ... The date and time was 7/21/2008 11:40 AM, and on a whim, Pegasus pounded out on the keyboard: ... Furthermore, to make your batch file robust, add the full path ... I interpret that the batch file cannot find "XXX.lnk" file even though the shortcut "XXX.lnk" does exist. ... I got the error message "File not found" for the shortcut command. ...
    (microsoft.public.windowsxp.general)
  • Re: Make an automatic task?
    ... Try this from a command prompt first: ... If that doesn't work and results in an error message, ... I wrote the batch file - named the icon do it.bat ... I thought that after clicking on the icon, ...
    (microsoft.public.windowsxp.customize)
  • basic problems with ocamlopt compiler
    ... doesn't work on ocamlopt. ... Here's the error message I get: ... 'ml' is not recognized as an internal or external command, ... program or batch file. ...
    (comp.lang.ml)
  • Re: System.Diagnostics.Process not working !! please help
    ... You must be having permissions problem. ... batch file is and goto the "security" tab, add the ASPNET user in it and ... >> missing using statements. ... >>> catch (Exception err) ...
    (microsoft.public.dotnet.languages.csharp)