AcManager.Tools.Helpers.WindowsHelper.ViewFile C# (CSharp) Method

ViewFile() private method

private ViewFile ( [ filename ) : void
filename [
return void
        public static void ViewFile([NotNull] string filename) {
            Process.Start("explorer", "/select," + filename);
        }

Usage Example

Beispiel #1
0
        private static async Task ResetService()
        {
            var secondResponse = ActionExtension.InvokeInMainThread(() => MessageDialog.Show(
                                                                        "Would you like to reset FTH system to make sure changes are applied? Otherwise, you would need to restart Windows.[br][br]It’ll need to run this command:[br][mono]Rundll32.exe fthsvc.dll,FthSysprepSpecialize[/mono][br][br]Or, Content Manager can simply prepare a .bat-file for you to inspect and run manually. [url=\"https://docs.microsoft.com/en-us/windows/win32/win7appqual/fault-tolerant-heap\"]Learn more[/url].",
                                                                        "One more thing",
                                                                        new MessageDialogButton(MessageBoxButton.YesNo, MessageBoxResult.Yes)
            {
                [MessageBoxResult.Yes] = "Reset automatically",
                [MessageBoxResult.No]  = "Prepare a .bat-file only"
            }));

            if (secondResponse == MessageBoxResult.Cancel)
            {
                return;
            }

            var filename = FilesStorage.Instance.GetTemporaryFilename("RunElevated", "FixFTH.bat");

            File.WriteAllText(filename, @"@echo off
:: More info: https://docs.microsoft.com/en-us/windows/win32/win7appqual/fault-tolerant-heap
echo Running rundll32.exe fthsvc.dll,FthSysprepSpecialize...
cd %windir%\system32
%windir%\system32\rundll32.exe fthsvc.dll,FthSysprepSpecialize
echo Done
pause");

            if (secondResponse == MessageBoxResult.Yes)
            {
                var procRunDll32 = ProcessExtension.Start("explorer.exe", new[] { filename }, new ProcessStartInfo {
                    Verb = "runas"
                });
                await procRunDll32.WaitForExitAsync().ConfigureAwait(false);

                Logging.Debug("Done: " + procRunDll32.ExitCode);
            }
            else if (secondResponse == MessageBoxResult.No)
            {
                WindowsHelper.ViewFile(filename);
            }
        }