473,386 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Howto: Include text data in a .net executable?

Dear subscribers

I'm currently creating a small application that will run at the end of a web
installation to configure a SQL Server. For this task I have a SQL batch
file in the same format as SQL Query Analyzer uses. I would prefer not to
merge the content of this file into the source code of configuration
application but instead keep the SQL commands in a text file included in the
executable, pretty much like resource data, for easy updates in the future.

My question is, what is the best way to attach text data to an .net
executable and still be able to extract it when the application is running?
What I want is to be able to do is to get the text data pretty much the same
way as if it was in a separate text file but with the difference that the
data is actually included in the executable.

Any help with this matter would be greatly appreciated.

Kind regards, Ola Theander
Jul 21 '05 #1
1 1753
I would include the file as an embedded resource in the assembly and
load the contents in as a stream at runtime. Get a reference to the
assembly containing the embedded resource and use the method
..GetManifestResourceStream() found on the Assembly class. Once you
have the resource as a stream, you can do as you please with the
content.

-KIRBY

On Thu, 19 Aug 2004 20:52:39 +0200, "Ola Theander"
<ol**********@otsystem.com> wrote:
Dear subscribers

I'm currently creating a small application that will run at the end of a web
installation to configure a SQL Server. For this task I have a SQL batch
file in the same format as SQL Query Analyzer uses. I would prefer not to
merge the content of this file into the source code of configuration
application but instead keep the SQL commands in a text file included in the
executable, pretty much like resource data, for easy updates in the future.

My question is, what is the best way to attach text data to an .net
executable and still be able to extract it when the application is running?
What I want is to be able to do is to get the text data pretty much the same
way as if it was in a separate text file but with the difference that the
data is actually included in the executable.

Any help with this matter would be greatly appreciated.

Kind regards, Ola Theander


--
Kirby Turner, MCSD, MCAD
www.whitepeaksoftware.com
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or...
11
by: Matt | last post by:
I'm posting this question for one of my developers who's not quite as newsgroup-savvy. Any suggestions? The question follows, along with relevant source code. -Matt I have a templated...
5
by: alejandro lapeyre | last post by:
How can I load / parse an HTML file with .NET? Thanks! Best regards, Alejandro Lapeyre
4
by: Ray Dukes | last post by:
What I am looking to do is map the implementation of interface properties and functions to an inherited method of the base class. Please see below. ...
1
by: Ola Theander | last post by:
Dear subscribers I'm currently creating a small application that will run at the end of a web installation to configure a SQL Server. For this task I have a SQL batch file in the same format...
8
by: Topper | last post by:
Hello. I have simple web folders structure: -ROOT - BIN WebService.dll WebService.asmx I need to use my WebService.dll not in bin folder - for example, in ROOT. How do i this? How can i do...
1
by: Marcel Brekelmans | last post by:
Hello, I know about the FileInfo.LastWriteTime() function. However, this is not always returning the modified date of the executable that I want: when you copy the executable to another...
7
by: patrik.kahari | last post by:
Is there a c++ function similar to getcwd that does not give you the working directory but the directory or path of the currently running executable? I need this because im porting a game that...
3
by: Mo | last post by:
Hi, Is there a way to include an executable (xxx.exe) file inside a c# console project so that the resulting project binary have only one final executable file? My c# console application is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.