Created
April 23, 2015 11:32
-
-
Save naichilab/66ada500266637f90b63 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
/// <summary> | |
/// 埋め込まれたリソースから取得 | |
/// </summary> | |
/// <param name="name">name</param> | |
/// <returns></returns> | |
public static Stream GetAssemblyStream(string name) { | |
Assembly asm = Assembly.GetExecutingAssembly(); | |
string filename = asm.GetManifestResourceNames() | |
.ToList() | |
.FirstOrDefault(n => n.Contains(name)); | |
if (!string.IsNullOrEmpty(filename)) { | |
return asm.GetManifestResourceStream(filename); | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment