Created
December 3, 2020 16:20
-
-
Save wk-j/5cd7e585baafcb476b24441deab7a32c to your computer and use it in GitHub Desktop.
Leak
This file contains 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
using System.IO; | |
using System.Reflection; | |
GetResource1("MyApp.Program.cs"); | |
GetResource2("MyApp.Program.cs"); | |
ReadFile(); | |
static string GetResource1(string path) { | |
var asm = Assembly.GetEntryAssembly(); | |
var stream = asm.GetManifestResourceStream(path); | |
var reader = new StreamReader(stream); | |
return reader.ReadToEnd(); | |
} | |
static string GetResource2(string path) { | |
var asm = Assembly.GetEntryAssembly(); | |
using var stream = asm.GetManifestResourceStream(path); | |
using var reader = new StreamReader(stream); | |
return reader.ReadToEnd(); | |
} | |
static void ReadFile() { | |
new FileStream("a.txt", FileMode.Open, FileAccess.Read); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment