コード例 #1
0
ファイル: WinUtil.cs プロジェクト: Gallimathias/KeePass
        internal static void ShowFileInFileManager(string strFilePath, bool bShowError)
        {
            if (string.IsNullOrEmpty(strFilePath))
            {
                Debug.Assert(false); return;
            }

            try
            {
                string strDir = UrlUtil.GetFileDirectory(strFilePath, false, true);
                if (NativeLib.IsUnix())
                {
                    NativeLib.StartProcess(strDir);
                    return;
                }

                string strExplorer = WinUtil.LocateSystemApp("Explorer.exe");

                if (File.Exists(strFilePath))
                {
                    NativeLib.StartProcess(strExplorer, "/select,\"" +
                                           NativeLib.EncodeDataToArgs(strFilePath) + "\"");
                }
                else
                {
                    NativeLib.StartProcess(strDir);
                }
            }
            catch (Exception ex)
            {
                if (bShowError)
                {
                    MessageService.ShowWarning(strFilePath, ex.Message);
                }
            }
        }