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

Bucher
Deleted Member

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

Edited 5 Years Ago by AnkitGuru: n/a

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

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

This article has been dead for over six months. Start a new discussion instead.