Swiss Army Knife
General utility tools for Scada Minds
Static Public Member Functions | List of all members
FileLocator Class Reference

Utilities to help locating files. More...

Static Public Member Functions

static DirectoryInfo TryGetSolutionDirectoryInfo (string? startingPath=null)
 This method will search parent directories from startingPath until it reaches a directory with a '.sln' file in it and return that. This is useful if you e.g. want to build a file path starting from your solution directory. The implementation is inspired by https://stackoverflow.com/questions/19001423/getting-path-to-the-parent-folder-of-the-solution-file-using-c-sharp . More...
 
static FileInfo GetFileStartingAtSolutionDirectory (params string[] pathPartsToJoin)
 Finds a file by starting to search from the nearest solution directory (looking from Directory.GetCurrentDirectory()). It will join the paths given and then return a FileInfo with the path. More...
 

Detailed Description

Utilities to help locating files.

Member Function Documentation

◆ GetFileStartingAtSolutionDirectory()

static FileInfo GetFileStartingAtSolutionDirectory ( params string[]  pathPartsToJoin)
inlinestatic

Finds a file by starting to search from the nearest solution directory (looking from Directory.GetCurrentDirectory()). It will join the paths given and then return a FileInfo with the path.

Parameters
pathPartsToJoinThe separate path parts to be given to Path.Join().
Returns
A fileInfo if the file could be found.
Exceptions
IOExceptionIf the file was not found this will throw an IOException.

◆ TryGetSolutionDirectoryInfo()

static DirectoryInfo TryGetSolutionDirectoryInfo ( string?  startingPath = null)
inlinestatic

This method will search parent directories from startingPath until it reaches a directory with a '.sln' file in it and return that. This is useful if you e.g. want to build a file path starting from your solution directory. The implementation is inspired by https://stackoverflow.com/questions/19001423/getting-path-to-the-parent-folder-of-the-solution-file-using-c-sharp .

Parameters
startingPathThe path to start searching from.
Returns
The DirectoryInfo of the solution file.
Exceptions
IOExceptionWill throw an IOException if no solution file could be found.

The documentation for this class was generated from the following file: