[quoted text, click to view] FrzzMan wrote:
> Sorry my English is not so good, it is not that I want to create a file
> only.
>
> What I want is to embed some content (in a file) with the app, and use
> that content whenever I need without having to pack the content (in a
> file) along with the setup.
>
> For example, here's one of the screnario:
>
> - I use an XML file to save user settings.
> - When the app start, it should check if the file exist or not,
> well-formed or not.
> - If ok -> proceed as normal.
> - If not ok -> delete current file, and create new file with default
> content.
> - That "default content" should be embeded into the executable file.
If you are using VS.NET, include the file in your project and mark it as
an "Embedded Resource" in the Build Action property for that file. If
you're using the command line compilers, use the /resource switch to
include the file as a resource in the generated assembly. When you
build the assembly, the contents of the file will be copied into a
resource that's bound in the assembly.
Now use the Assembly.GetManifestResourceStream() method to read the file
from the assembly resource.
Do a search on the net for "GetManifestResourceStream" to get some examples.
[quoted text, click to view] >
> Hope you understand me, if not, just tell, I'll have my brother post
> what I'm thinking :D His English much better than me :D
>
> Ignacio Machin ( .NET/ C# MVP ) wrote:
>
>> Hi,
>>
>> Your post is confusing so I will get you a couple of scanarios and
>> solutions.
>>
>> If you do not care if the file exist before run the first time, just
>> create
>> it, when you run it again it will be already created
>> You can include this file ( or a copy of it ) in the project and mark
>> it as
>> content, this will make it copied when u make a setup project.
>>
>> you may use a config file to indicate where the file will be located,
>> using
>> this form you can set where the file will be located, I have a similar
>> scenario than this, what I did was create the file in c:\temp in my
>> machine
>> so it will always exist , then when I going to deploy it change the
>> config
>> file to the location I need.
>>
>> hope this help,
>>
--