Member Avatar for Bucher

Hello all, I just joined the site.

I hope someone can help me with a minor problem, I have been searching both this site and google for the anwser... but keep getting stuck.

A dialog with a textbox is reading a text file within the project like this

Private Sub StandardPharses_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim mystream As System.IO.Stream = System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream("Textfile1.txt")
        Using reader As New IO.StreamReader(mystream)
            ' Read the contents into TextBox
            TextBox1.Text = reader.ReadToEnd
        End Using
    End Sub

That works fine, but how to save the edited text back to the file when I hit Save

you want to update the same file? first delete the content and using io.write u can write back and save...

i believe you can't possibly write back since the file you are using is read-only. It must be embedded into the exe(Check if I am right). You can embed files only before compiling or if you could find a way to manipulate an exe but that will just corrupt the exe or may produce runtime inconsistency, in other words not-poossible. rather store data in .config files

Also System.IO helps writing to files on the disk ur file is probably not stored on disk :) so not io functionality can work

Member Avatar for Bucher

you want to update the same file? first delete the content and using io.write u can write back and save...

Thanks for your reply, can you provide me with an example code? as I have tried something like that with no luck

Member Avatar for Bucher

i believe you can't possibly write back since the file you are using is read-only. It must be embedded into the exe(Check if I am right). You can embed files only before compiling or if you could find a way to manipulate an exe but that will just corrupt the exe or may produce runtime inconsistency, in other words not-poossible. rather store data in .config files

Also System.IO helps writing to files on the disk ur file is probably not stored on disk :) so not io functionality can work

Thanks for your reply.. yeah you might be right about the read only.. I will look into useing a .config insted

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.