0

i'm trying to run a simple executable using an Azure Web Role.

  • The executable is stored in the Web Role's local storage.
  • The executable produces a log.txt file once it has been run.

This is the method I am using to run the executable:

    public void RunExecutable(string path)
    {
        Process.Start(path);
    }

Where path is localStorage.RootPath + "Application.exe"

The problem I am facing is that when I open the local storage folder the executable is there however there is no log.txt file.

I have tested the executable, it works if I manually run it, it produces the log.txt file.

Can anyone see the problem?

Amicable
  • 3,115
  • 3
  • 49
  • 77
Sami
  • 1,374
  • 1
  • 16
  • 43

2 Answers2

1

Try setting an explicit WorkingDirectory for the process... I wonder if log.txt is being created, just not where you expect. (Or perhaps the app is trying to create log.txt but failing because of the permissions on the directory it's trying to create it in.)

user94559
  • 59,196
  • 6
  • 103
  • 103
  • I'd like to keep the local storage as the working directory as i would then like to upload the log file to a blob storage container. – Sami Mar 07 '12 at 00:57
  • 2
    That's great. Then you should use that. That won't be the default working directory. See http://stackoverflow.com/questions/114928/net-process-start-default-directory for how to set the working directory. – user94559 Mar 08 '12 at 00:55
  • Thanks, that worked perfectly, I assumed the working directory was the directory from which the application is held. – Sami Mar 08 '12 at 16:42
  • Glad you got it working! FYI, the default working directory is whatever the working directory of the parent process is. (It just inherits.) – user94559 Mar 08 '12 at 21:09
1

If you remote desktop into the instance, can't you find the file created at E:\approot\ folder ? As Steve said, using a WorkingDirectory for the process will fix the issue

You can use Environment.GetEnvironmentVariable("RoleRoot") to construct the URL to your application root

  • Thanks for your response, I am unfamiliar with working directories could you please explain how to allocated a working directory for the process. Would I use Directory.SetCurrentDirectory? – Sami Mar 07 '12 at 15:21