Created
February 13, 2015 22:00
-
-
Save davidalpert/9ef9fbda81c2b6dcdffb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let private getFromResource resourceName = | |
let assem = System.Reflection.Assembly.GetExecutingAssembly() | |
try | |
use stream = assem.GetManifestResourceStream(resourceName) | |
use reader = new System.IO.StreamReader(stream) | |
reader.ReadToEnd(); | |
with | |
| ex -> | |
let errorMessageBase = sprintf "%s not found; available resources include:" resourceName | |
let errorMessage = | |
assem.GetManifestResourceNames() | |
|> Seq.fold (fun acc el -> sprintf "%s%s%s" acc nl (sprintf "- %s" el)) errorMessageBase | |
failwith errorMessage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment