IEexec and CurrentDirectory

Another one from the internal aliases...

Q:

I launch my managed app in internet
explorer via command line as

C:\tmp> %programfiles%\Internet
Explorer\iexplore.exe https://mywebserver/myapp.exe

It looks to me that the
Environment.CurrentDirectory (as returned by myapp) for the IEexec process is
“Desktop”. Is that right?

Does anyone have any information
about the CurrentDirectory and IEexec process.

 

A:

The
following code:

string envCurDir =
Environment.CurrentDirectory;
Console.WriteLine("Environment.CurrentDirectory
= {0}", envCurDir);

string baseDir =
AppDomain.CurrentDomain.BaseDirectory;
Console.WriteLine("AppDomain.CurrentDomain.BaseDirectory
= {0}", baseDir);

generates this output when started from https://Server/iedownload/!/

Environment.CurrentDirectory = C:\Documents and
Settings\konste\Desktop
AppDomain.CurrentDomain.BaseDirectory =
https://Server/iedownload/!/

Probably you want just use AppDomain.CurrentDomain.BaseDirectory instead
of Environment.CurrentDirectory.

Additional consideration is that to use Environment.CurrentDirectory your
application must be given FileIOPermission in order to run from
Internet/Intranet location, while to use AppDomain.CurrentDomain.BaseDirectory default permissions are
enough.