Reputation: 157
I'd like to have a GUI that gives the user two options:
This would be helpful in that the user would not need to carry around all our key files, but it would still allow flexibility if a new key file needed to be added.
My code is currently working for option #1. I use:
readFile = new StreamReader(KeyFileFullPath);
where KeyFileFullPath is the filepath to the key file defined by the openFileDialog.
I would like to use the same streamReader for option #2, but I'm having trouble pointing the reader at the resource files.
From this question, I attempted the following:
_assembly = Assembly.GetExecutingAssembly();
readFile = new StreamReader(_assembly.GetManifestResourceStream(TM_Decoder.Properties.Resources._7p1_HOB_Key));
I navigated to ..."_7p1_HOB_Key" using C#'s autocomplete, so I'd expect it to be pointing me at something that actually exists. However, when I try to run the code, I get this error:
"Value cannot be null.Parameter name: stream"
Based on this, I tried looking up the ManifestResourceNames, but all it had was: "TM_Decoder.Form1.resources" and "TM_Decoder.Properties.Resources.resources"
Neither of these actually point at the key file I have loaded into my project's resources.
Thanks in advance for any help in getting the streamReader to point at the resource text file!
Edits (in response to SLaks suggestions):
Upvotes: 1
Views: 1009
Reputation: 887285
TM_Decoder.Properties.Resources._7p1_HOB_Key
is a string containing the actual contents, not the resource name.
"TM_Decoder.Resources._7p1_HOB_Key"
is the resource name.
Upvotes: 2