c# - Reading an embedded text file -


i have created full project works perfectly. problem concerns setup project. when use on computer, text file cannot found if inside resource folder during deployment!

how can ensure program find text files after installing software on computer!

i have been looking solution in vain. please me sort out. if can full code happy!

first set build action of text file "embeddedresource".

then read file in code:

var assembly = assembly.getexecutingassembly(); var resourcename = "assemblyname.myfile.txt";  using (stream stream = assembly.getmanifestresourcestream(resourcename)) {     using (streamreader reader = new streamreader(stream))     {         string result = reader.readtoend();     } } 

if can't figure out name of embedded resource find names , should obvious file is:

assembly.getmanifestresourcenames(); 

this assuming want text file embedded in assembly. if not, might want change setup project include text file during installation.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -