Skip to content

Instantly share code, notes, and snippets.

@JordanMarr
Created August 9, 2022 15:45
Show Gist options
  • Save JordanMarr/b8c66aa7d0ca790be8ddfcb0a1824a58 to your computer and use it in GitHub Desktop.
Save JordanMarr/b8c66aa7d0ca790be8ddfcb0a1824a58 to your computer and use it in GitHub Desktop.
CurrentFile.fs Utility
namespace Utils
open System.IO
open System.Runtime.CompilerServices
type CurrentFile =
static member Path([<CallerFilePath>] ?file: string) =
file |> Option.defaultValue ""
static member Directory([<CallerFilePath>] ?file: string) =
file |> Option.defaultValue "" |> Path.GetDirectoryName
static member Relative(relative: string, [<CallerFilePath>] ?file: string) =
let directory = file |> Option.defaultValue "" |> Path.GetDirectoryName
Path.Combine(directory, relative)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment