Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Internal Solotion Explorer File Interaction

Status
Not open for further replies.

WoundEdGoat

Programmer
May 10, 2002
39
0
0
CA
I added a file called Encryption.dat to my project and it is now in the solution explorer window. How can I access the data in the file through code without having to make it into an external file for the exe to work with after compiling? If I cannot do this, is there an alternative method I can use without having to hardcode an array or collection?
 
1. Select the file in the solution explorer. In the properties when choose Embedded Resource for the Build Action.


2. The file I've embedded is called ip.txt. However you will need to append the EXE name (messsinhome) to the file name.


Code:
Dim s As System.IO.Stream = System.Reflection.Assembly.GetEntryAssembly.GetManifestResourceStream("messinhome.ip.txt")
        Dim sr As New System.IO.StreamReader(s)

        With sr
            Do While .Peek >= 0
                Console.WriteLine(.ReadLine())
            Loop
            .Close()
        End With
        s.Close()
        s = Nothing
        sr = Nothing

Scott
Programmer Analyst
<{{><
 
Excellent. Thank you very much. That is exactly what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top