ResourceWriter question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CSharper

    ResourceWriter question

    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,
  • Jeroen Mostert

    #2
    Re: ResourceWriter question

    CSharper wrote:
    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.

    --
    J.

    Comment

    • CSharper

      #3
      Re: ResourceWriter question

      On Jun 19, 6:22 pm, Jeroen Mostert <jmost...@xs4al l.nlwrote:
      CSharper wrote:
      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.
      >
      --
      J.http://symbolsprose.blogspot.com
      Thanks and thats what I did and it is working.

      Comment

      Working...