ResourceWriter question

  • Thread starter Thread starter CSharper
  • Start date Start date
C

CSharper

I have a resource file I have created using ResourceWriter, next time
when it runs, I want to check if the resource already exists and if
does, I want to open it and add more objects to resource. What is the
correct way of doing it?

If I do ResourceWriter rw = new ResourceWriter(resourcename)
it will overwrite the existing resource file, is there an option to
open the resource file in a read/write mode so that I can remove any
objects I want to remove and add objects I want to add?

Thanks,
 
CSharper said:
I have a resource file I have created using ResourceWriter, next time
when it runs, I want to check if the resource already exists and if
does, I want to open it and add more objects to resource. What is the
correct way of doing it?

If I do ResourceWriter rw = new ResourceWriter(resourcename)
it will overwrite the existing resource file, is there an option to
open the resource file in a read/write mode so that I can remove any
objects I want to remove and add objects I want to add?

No. There's ResourceReader and ResourceWriter, but no ResourceEditor. To
achieve what you want to achieve, you can use ResourceReader to read the
existing resources and write them out (except the ones you don't want, and
adding the ones you do want) to a ResourceWriter. Both classes can operate
on streams, so you can use MemoryStream to hold the intermediate results
before overwriting the old file.
 
No. There's ResourceReader and ResourceWriter, but no ResourceEditor. To
achieve what you want to achieve, you can use ResourceReader to read the
existing resources and write them out (except the ones you don't want, and
adding the ones you do want) to a ResourceWriter. Both classes can operate
on streams, so you can use MemoryStream to hold the intermediate results
before overwriting the old file.

Thanks and thats what I did and it is working.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top