how to embed text file in asp.net application

G

Guoqi Zheng

I have an ASP.NET application, I need to distribute it to clients. I used
some text file to stroed database scripts, .sql files.

Those .sql files are very very important part of the application, I like to
hide them from clients.

Is there a way to embed those .sql text file into the compiled .dll file? so
that client can not read it???
 
T

Todd Acheson

Hello Guoqi,

This has worked for me on projects where I need to embed something in the
DLL:

In the solution explorer, set your SQL file(s) to be "Embedded Content"

'some vb.net code to access your embedded resource:
Dim executing_assembly As System.Reflection.Assembly = Me.GetType.Assembly.GetEntryAssembly()
Dim my_namespace As String = executing_assembly.GetName().Name.ToString()
Dim text_stream As Stream = executing_assembly.GetManifestResourceStream(my_namespace
+ "MySqlFile.sql")
If Not (text_stream Is Nothing) Then
'read your data from text_stream here. Supply your own code to to whatever
you need
'if you don't know how to do this, look in the MSDN library for help
on file IO
End If

HTH
Todd A.
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top