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

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
SWIK
  • 714
  • 7
  • 12
  • 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. – Peter Duniho Sep 03 '19 at 06:21
  • https://stackoverflow.com/questions/3314140 – Dave Anderson Sep 03 '19 at 06: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. – Peter Duniho Sep 03 '19 at 06:33

0 Answers0