Add folder existence check for USERPROFILE environment variable.

This commit is contained in:
qianlifeng
2014-07-01 18:14:41 +08:00
parent 6870e03ffe
commit 6352408d87

View File

@@ -299,7 +299,7 @@ namespace Wox.Infrastructure
{
string oldCwd = Environment.CurrentDirectory;
string home = Environment.GetEnvironmentVariable("USERPROFILE");
if(!string.IsNullOrEmpty(home)) Environment.CurrentDirectory = home;
if(!string.IsNullOrEmpty(home) && Directory.Exists(home)) Environment.CurrentDirectory = home;
ShellExecCmdLine(
IntPtr.Zero,
errorDialogHwnd,
@@ -308,7 +308,7 @@ namespace Wox.Infrastructure
global::System.Diagnostics.ProcessWindowStyle.Normal,
ShellExecCmdLineFlags.SECL__IGNORE_ERROR | ShellExecCmdLineFlags.SECL_USE_IDLIST | ShellExecCmdLineFlags.SECL_LOG_USAGE | (showErrorDialog ? 0 : ShellExecCmdLineFlags.SECL_NO_UI)
);
if (!string.IsNullOrEmpty(home)) Environment.CurrentDirectory = oldCwd;
if (!string.IsNullOrEmpty(home) && Directory.Exists(home)) Environment.CurrentDirectory = oldCwd;
}
else
{ // Device not ready 0x80070015