Table of Contents

Class PHWin

Namespace
SunamoWinStd
Assembly
SunamoWinStd.dll

Windows-specific process helper for browser management, editor launching, and file operations.

public class PHWin
Inheritance
PHWin
Inherited Members
Extension Methods

Properties

BrowserPaths

Browser executable paths indexed by browser type. Does not contain Browsers.None.

public static Dictionary<Browsers, string> BrowserPaths { get; set; }

Property Value

Dictionary<Browsers, string>

ExecutablePaths

Executable paths indexed by executable name.

public static Dictionary<string, string> ExecutablePaths { get; set; }

Property Value

Dictionary<string, string>

Opened

Number of browser tabs opened in current session.

public static int Opened { get; set; }

Property Value

int

PreferredEditor

Preferred code editor to use for opening files.

public static Editor PreferredEditor { get; set; }

Property Value

Editor

WaitIfTen

Milliseconds to wait after every 10 opened tabs. 0 means no wait.

public static int WaitIfTen { get; set; }

Property Value

int

Methods

AddBrowser()

Adds the default browser to the browser paths dictionary.

public static void AddBrowser()

AddBrowser(Browsers)

Adds the specified browser executable path to the browser paths dictionary.

public static string AddBrowser(Browsers browser)

Parameters

browser Browsers

The browser type to add.

Returns

string

The executable path of the browser, or empty string if not found.

AddBrowsers()

Initializes browser executable paths for all known browsers.

public static void AddBrowsers()

BrowsersWhichDontHaveExeInDefinedPath()

Returns list of browser executable paths that do not exist on disk.

public static List<string> BrowsersWhichDontHaveExeInDefinedPath()

Returns

List<string>

List of missing browser executable paths.

Code(ILogger, string, bool, int?)

Opens a file in VS Code or Cursor (if installed).

public static void Code(ILogger logger, string filePath, bool isThrowingOnError = false, int? openOnLine = null)

Parameters

logger ILogger

Logger instance.

filePath string

File path to open.

isThrowingOnError bool

Whether to throw on error.

openOnLine int?

Optional line number to open at.

CodeInsider(ILogger, string, bool, int?)

Opens a file in VS Code Insiders.

public static void CodeInsider(ILogger logger, string filePath, bool isThrowingOnError = false, int? openOnLine = null)

Parameters

logger ILogger

Logger instance.

filePath string

File path to open.

isThrowingOnError bool

Whether to throw on error.

openOnLine int?

Optional line number to open at.

Codium(ILogger, string, bool, int?)

Opens a file in VSCodium.

public static void Codium(ILogger logger, string filePath, bool isThrowingOnError = false, int? openOnLine = null)

Parameters

logger ILogger

Logger instance.

filePath string

File path to open.

isThrowingOnError bool

Whether to throw on error.

openOnLine int?

Optional line number to open at.

ExecutableOfAllBrowsers()

Prints executable paths of all known browsers to console.

public static void ExecutableOfAllBrowsers()

IsUsed(string)

Checks if a file is currently in use by any process.

public static bool IsUsed(string fullPath)

Parameters

fullPath string

Full path to the file.

Returns

bool

True if the file is locked by a process.

OpenFolder(string)

Opens a folder in Windows Explorer.

public static void OpenFolder(string folder)

Parameters

folder string

Folder path to open.

OpenFolderInTotalcmd(ILogger, string, bool)

Opens a folder in Total Commander.

public static void OpenFolderInTotalcmd(ILogger logger, string folder, bool isThrowingOnError = false)

Parameters

logger ILogger

Logger instance.

folder string

Folder path to open.

isThrowingOnError bool

Whether to throw on error.

OpenInAllBrowsers(ILogger, IList<string>)

Opens multiple URIs in all known browsers.

public static void OpenInAllBrowsers(ILogger logger, IList<string> uris)

Parameters

logger ILogger

Logger instance.

uris IList<string>

List of URIs to open.

OpenInAllBrowsers(ILogger, string)

Opens a single URI in all known browsers.

public static void OpenInAllBrowsers(ILogger logger, string uri)

Parameters

logger ILogger

Logger instance.

uri string

URI to open.

OpenInBrowser(ILogger, Browsers, string, int, bool, bool)

Opens a URL in the specified browser.

public static void OpenInBrowser(ILogger logger, Browsers browser, string text, int waitMs = 500, bool isForceAttemptingHttps = false, bool isThrowingIfNotValidUrl = false)

Parameters

logger ILogger

Logger instance.

browser Browsers

Browser to use.

text string

URL or path to open.

waitMs int

Milliseconds to wait after opening. 0 is not recommended as Google may show captcha for many searches.

isForceAttemptingHttps bool

Whether to force HTTPS prefix.

isThrowingIfNotValidUrl bool

Whether to throw if the URL is invalid.

OpenInBrowser(ILogger, string, int)

Opens a URL in the default browser.

public static void OpenInBrowser(ILogger logger, string uri, int waitMs = 500)

Parameters

logger ILogger

Logger instance.

uri string

URL to open.

waitMs int

Milliseconds to wait after opening. 0 is not recommended as Google may show captcha for many searches.

OpenInBrowserAutomaticallyCountOfOpened(ILogger, Browsers, string, int)

Opens a URL in the specified browser and tracks open count.

public static void OpenInBrowserAutomaticallyCountOfOpened(ILogger logger, Browsers browser, string text, int waitMs = 500)

Parameters

logger ILogger

Logger instance.

browser Browsers

Browser to use.

text string

URL or path to open.

waitMs int

Milliseconds to wait after opening. 0 is not recommended as Google may show captcha for many searches.

PreferredEditorOpen(ILogger, string, bool)

Opens a file in the preferred editor.

public static void PreferredEditorOpen(ILogger logger, string filePath, bool isThrowingOnError = false)

Parameters

logger ILogger

Logger instance.

filePath string

File path to open.

isThrowingOnError bool

Whether to throw on error.

SaveAndOpenInBrowser(ILogger, Browsers, string)

Saves HTML content to a temp file and opens it in the specified browser.

public static void SaveAndOpenInBrowser(ILogger logger, Browsers browser, string htmlContent)

Parameters

logger ILogger

Logger instance.

browser Browsers

Browser to use.

htmlContent string

HTML content to save and open.

WebStorm64(ILogger, string, bool)

Opens a file in WebStorm 64-bit.

public static void WebStorm64(ILogger logger, string filePath, bool isThrowingOnError = false)

Parameters

logger ILogger

Logger instance.

filePath string

File path to open.

isThrowingOnError bool

Whether to throw on error.