adding files at compile time

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

    adding files at compile time

    I have a situation, where I need to add 4 or 5 data files (they change
    every time I build) in my project during build time and somehow I need
    a way to access these files during runtime.
    So I have 2 questions
    1. Is it possible to identify all the files in the resource file
    during runtime by name of the file?
    2. Is it possible to add files to a project at build time to make an
    exe with those files?
    Thanks.
  • RobinS

    #2
    Re: adding files at compile time

    You can add them to your project, set Build Action to "Content" and the
    "Copy to Output Dir" to "Copy Always". Then you can load it by its relative
    path to the ApplicationPath .

    Or you can add them as an embedded resource.

    Is that what you mean? You just want to include them and then access them?

    RobinS.
    GoldMail, Inc.
    --------------------------
    "DBC User" <dbcuser@gmail. comwrote in message
    news:de176644-68ec-42f0-a315-1386d55faedb@u7 2g2000hsf.googl egroups.com...
    >I have a situation, where I need to add 4 or 5 data files (they change
    every time I build) in my project during build time and somehow I need
    a way to access these files during runtime.
    So I have 2 questions
    1. Is it possible to identify all the files in the resource file
    during runtime by name of the file?
    2. Is it possible to add files to a project at build time to make an
    exe with those files?
    Thanks.

    Comment

    • DBC User

      #3
      Re: adding files at compile time

      On Mar 5, 11:44 pm, "RobinS" <rob...@imnotte lling.comwrote:
      You can add them to your project, set Build Action to "Content" and the
      "Copy to Output Dir" to "Copy Always". Then you can load it by its relative
      path to the ApplicationPath .
      >
      Or you can add them as an embedded resource.
      >
      Is that what you mean? You just want to include them and then access them?
      >
      RobinS.
      GoldMail, Inc.
      --------------------------"DBC User" <dbcu...@gmail. comwrote in message
      >
      news:de176644-68ec-42f0-a315-1386d55faedb@u7 2g2000hsf.googl egroups.com...
      >
      >
      >
      I have a situation, where I need to add 4 or 5 data files (they change
      every time I build) in my project during build time and somehow I need
      a way to access these files during runtime.
      So I have 2 questions
      1. Is it possible to identify all the files in the resource file
      during runtime by name of the file?
      2. Is it possible to add files to a project at build time to make an
      exe with those files?
      Thanks.- Hide quoted text -
      >
      - Show quoted text -
      I would like to add them as embedded resource. This is what I found so
      far, I could write a seperate program which will generate the resource
      file with all the required files and then build the new program which
      need to access it with the new resource. So I would like to find a way
      to add the text files to resource file and way to read it back.
      Thanks.

      Comment

      • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

        #4
        Re: adding files at compile time



        "DBC User" wrote:
        On Mar 5, 11:44 pm, "RobinS" <rob...@imnotte lling.comwrote:
        You can add them to your project, set Build Action to "Content" and the
        "Copy to Output Dir" to "Copy Always". Then you can load it by its relative
        path to the ApplicationPath .

        Or you can add them as an embedded resource.

        Is that what you mean? You just want to include them and then access them?

        RobinS.
        GoldMail, Inc.
        --------------------------"DBC User" <dbcu...@gmail. comwrote in message

        news:de176644-68ec-42f0-a315-1386d55faedb@u7 2g2000hsf.googl egroups.com...


        >I have a situation, where I need to add 4 or 5 data files (they change
        every time I build) in my project during build time and somehow I need
        a way to access these files during runtime.
        So I have 2 questions
        1. Is it possible to identify all the files in the resource file
        during runtime by name of the file?
        2. Is it possible to add files to a project at build time to make an
        exe with those files?
        Thanks.- Hide quoted text -
        - Show quoted text -
        >
        I would like to add them as embedded resource. This is what I found so
        far, I could write a seperate program which will generate the resource
        file with all the required files and then build the new program which
        need to access it with the new resource. So I would like to find a way
        to add the text files to resource file and way to read it back.
        Thanks.
        Then set the "Build Action" to "Embedded Resource". Do you mean the
        filenames change every build or the file contents change every build?
        >

        Comment

        • DBC User

          #5
          Re: adding files at compile time

          On Mar 6, 11:27 am, Family Tree Mike
          <FamilyTreeM... @discussions.mi crosoft.comwrot e:
          "DBC User" wrote:
          On Mar 5, 11:44 pm, "RobinS" <rob...@imnotte lling.comwrote:
          You can add them to your project, set Build Action to "Content" and the
          "Copy to Output Dir" to "Copy Always". Then you can load it by its relative
          path to the ApplicationPath .
          >
          Or you can add them as an embedded resource.
          >
          Is that what you mean? You just want to include them and then access them?
          >
          RobinS.
          GoldMail, Inc.
          --------------------------"DBC User" <dbcu...@gmail. comwrote in message
          >
          >news:de17664 4-68ec-42f0-a315-1386d55faedb@u7 2g2000hsf.googl egroups.com....
          >
          I have a situation, where I need to add 4 or 5 data files (they change
          every time I build) in my project during build time and somehow I need
          a way to access these files during runtime.
          So I have 2 questions
          1. Is it possible to identify all the files in the resource file
          during runtime by name of the file?
          2. Is it possible to add files to a project at build time to make an
          exe with those files?
          Thanks.- Hide quoted text -
          >
          - Show quoted text -
          >
          I would like to add them as embedded resource. This is what I found so
          far, I could write a seperate program which will generate the resource
          file with all the required files and then build the new program which
          need to access it with the new resource. So I would like to find a way
          to add the text files to resource file and way to read it back.
          Thanks.
          >
          Then set the "Build Action" to "Embedded Resource".  Do you mean the
          filenames change every build or the file contents change every build?  
          >
          >
          Yes that is correct. So here is what I am planning to do
          1. All the input files required will be staged in a temp folder for
          me. So I will have one program which will read each file and create a
          console c# program to add it to a resource file. This step only
          creates an output c# program.
          2. Now I run command line compiler to build and then run the program.
          The output will be a resource file.
          3. Now build my actual program which expects all the files in resource
          file to run at the destination with the resource file created at step
          2.
          4. Copy the final exe to destination server and run it.

          I got al step 2, 3 and 4 except the part where how to add a file to a
          resource file and read a file from resource file. All the example I
          have seen so far are image files. I couldn't find single example for
          adding a text/binary file to a resource file.

          So if someone can help me on how to write a text file to resource file
          and read the text file back from resource file, it would be greatful.

          Thanks again.

          Comment

          • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

            #6
            Re: adding files at compile time



            "DBC User" wrote:
            On Mar 6, 11:27 am, Family Tree Mike
            <FamilyTreeM... @discussions.mi crosoft.comwrot e:
            "DBC User" wrote:
            On Mar 5, 11:44 pm, "RobinS" <rob...@imnotte lling.comwrote:
            You can add them to your project, set Build Action to "Content" and the
            "Copy to Output Dir" to "Copy Always". Then you can load it by its relative
            path to the ApplicationPath .
            Or you can add them as an embedded resource.
            Is that what you mean? You just want to include them and then access them?
            RobinS.
            GoldMail, Inc.
            --------------------------"DBC User" <dbcu...@gmail. comwrote in message
            news:de176644-68ec-42f0-a315-1386d55faedb@u7 2g2000hsf.googl egroups.com....
            >I have a situation, where I need to add 4 or 5 data files (they change
            every time I build) in my project during build time and somehow I need
            a way to access these files during runtime.
            So I have 2 questions
            1. Is it possible to identify all the files in the resource file
            during runtime by name of the file?
            2. Is it possible to add files to a project at build time to make an
            exe with those files?
            Thanks.- Hide quoted text -
            - Show quoted text -
            I would like to add them as embedded resource. This is what I found so
            far, I could write a seperate program which will generate the resource
            file with all the required files and then build the new program which
            need to access it with the new resource. So I would like to find a way
            to add the text files to resource file and way to read it back.
            Thanks.
            Then set the "Build Action" to "Embedded Resource". Do you mean the
            filenames change every build or the file contents change every build?
            Yes that is correct. So here is what I am planning to do
            1. All the input files required will be staged in a temp folder for
            me. So I will have one program which will read each file and create a
            console c# program to add it to a resource file. This step only
            creates an output c# program.
            2. Now I run command line compiler to build and then run the program.
            The output will be a resource file.
            3. Now build my actual program which expects all the files in resource
            file to run at the destination with the resource file created at step
            2.
            4. Copy the final exe to destination server and run it.
            >
            I got al step 2, 3 and 4 except the part where how to add a file to a
            resource file and read a file from resource file. All the example I
            have seen so far are image files. I couldn't find single example for
            adding a text/binary file to a resource file.
            >
            So if someone can help me on how to write a text file to resource file
            and read the text file back from resource file, it would be greatful.
            >
            Thanks again.
            >
            The process for adding the files as a resource should be the same whether
            the file is a bitmap/jpeg/tiff or the text of "War and Peace". You get the
            files out at runtime with GetManifestReso urceStream and read it with a
            StreamReader, rather than sending it to the constructor for an image.


            Comment

            Working...