in this below code has error .

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim FilePath As String = My.Computer.FileSystem.SpecialDirectories.Desktop
        'System.IO.File.WriteAllBytes(FilePath & "\filename.extension", My.Resources.filename)
        System.IO.File.WriteAllBytes(FilePath & "\wsha.txt", My.Resources.wsha)



        Using reader As StreamReader = New StreamReader("wsha.txt")

            Do While (True)
                Dim line As String = reader.ReadLine
                If line Is Nothing Then
                    Exit Do
                End If
                Dim words As String() = line.Split("/")
                Dim word As String
                For Each word In words
                    If word = TextBox1.Text Then
                        TextBox2.Text = words(+1)
                    End If
                Next
            Loop
        End Using

There is no path to your resources it's already embeded in your exe app but instead you can use the text inside (only to copy)
Like this:

Dim Text As New RichTextBox
Dim FilePath As String = My.Computer.FileSystem.SpecialDirectories.Desktop
Dim lines() As String = My.Resources.wsha.Split(Environment.NewLine)
For Each line As String In lines
Text.Text = Text.Text & vbNewLine & line
Next
Dim Copy As New System.IO.StreamWriter(FilePath & "\wsha.txt")
Copy.Write(Text.Text)
Copy.Close()

Edited 2 Years Ago by oussama_1

does not work code , i want use StreamReader not use StreamWrite and i want to create a Dictionary by using example file.txt .

can not find Path resource in textfile

well there is no path (you can get objets,strings.. from your resources).
my code works fine, your code shows that you want to copy a textfile from resources:

        System.IO.File.WriteAllBytes(FilePath & "\wsha.txt", My.Resources.wsha)

the streamReader wont work because your textfile in the resources is no longer a file so its not supported by system.io.streamReader. but you can import the text like this:

Dim lines() As String = My.Resources.wsha.Split(Environment.NewLine)
For Each line As String In lines
Richtextbox1.Text = Richtextbox1.Text & vbNewLine & line
Next

Good luck

Edited 2 Years Ago by oussama_1

at now your suggest create dictionary English to another language by use text file ? please give me all codes .

oh, i recommand that you use a dictionary api but it depends if you can find one with the languages you want.

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