1

I have a code that opens file using filestream as below:-

using (var stream = new FileStream("abc.txt", FileMode.Open, FileAccess.ReadWrite)) 

I do not want to have it in any any directory rather I want it in embedded resource. I just copied the file in solution explorer and changed build action to embedded resource, now what should I do next to get it worked and achieve similar code behavior as above! Thanks

3
  • Your question is too broad, particularly because doing exactly what you're asking is impossible. An embedded resource is, by definition, not a file. But FileStream works only on files. Commented Sep 3, 2019 at 6:21
  • stackoverflow.com/questions/3314140 Commented Sep 3, 2019 at 6:21
  • Given that what you're asking for literally, is just not possible, you have two alternatives: treat the resource as a Stream, not FileStream; or copy the resource out to an actual file, and then use FileStream on that file. See marked duplicates for these two options. Commented Sep 3, 2019 at 6:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.