2

I'm working for some class library project and required to store some tiny data in a text file say JSON and need to do the read/write operations.

  • This DLL will be referenced to any project in the C# development so I am unable to hard-code with the file absolute path.
  • I need to do with the embed resource and I am unable to write it back. How can I achieve this write operation within the class library ?

this helped me to read such file content and stuck in writing it back

Community
  • 1
  • 1
Prajwal Bhat
  • 303
  • 2
  • 5
  • 21
  • If the file path is going to depend on the application, why can't the library require that information from the application? For example as a string argument on a method or constructor? Then the application can store it however it likes, such as in a config value. – David Feb 20 '17 at 18:31
  • I agree!! But developing some independent module. Need to store some iteration count within the library. I can't go with config file – Prajwal Bhat Feb 20 '17 at 18:34
  • Possible duplicate of [How To Read, Then Write To An Embedded Resource In C#](http://stackoverflow.com/questions/3736267/how-to-read-then-write-to-an-embedded-resource-in-c-sharp) – David Culp Feb 20 '17 at 19:01
  • Short answer is that you can't write to an embedded resource -- see duplicate question for more details. – David Culp Feb 20 '17 at 19:02
  • You are right @DavidCulp, But I need to read/write to file operation in that Library. Can't go with database. Any alternate way I can do file operation in that ? – Prajwal Bhat Feb 21 '17 at 15:45
  • Maybe you could update the question with information about what it is you want to do -- instead of just one implementation. What is the expected result? where is it going to be used? what restrictions do you have? and so on. – David Culp Feb 21 '17 at 17:25

0 Answers0