myCoolFile = chosefolder.SelectedPath & "\" & NameofUal.Text & ".Ual"
          Try
        Dim myCoolWriter As New IO.StreamWriter(myCoolFile, False , [U][I][B]????[/B][/I][/U]) <-<-<-
        For i As Integer = 0 To Mainfrm.ShellProgramslis.Items.Count - 1
            myCoolWriter.WriteLine(Mainfrm.ShellProgramslis.Items(i).ToString & "~" & Mainfrm.myArrayList(i))
        Next
        myCoolWriter.Close()
           Catch Erroronwrite As Exception
          End Try

Ive got some problems how do i say that
thee encoding should look under my combobox of witch one to use(the item that has been chosen):-/

Recommended Answers

All 2 Replies

Member Avatar for Unhnd_Exception

One thing you could do is fill the combobox with all the system.Text.EncodingInfo's and set the combobox's DisplayMember to "DisplayName" and the use the System.Text.Encodings.GetEncoding(Ctype(combox.selecteditem,System.text.EnodingInfo).CodePage) to get the encoding.

An easier way is to make a function to return the encoding based on the combobox's string selected item.

Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
       
        Dim FilePath As String = "C:\No.txt"
        Dim FileStreamWriter As New System.IO.StreamWriter(FilePath, False, GetEncoding)

    End Sub

    Private Function GetEncoding() As System.Text.Encoding
        If ComboBoxEncoding.SelectedIndex = -1 Then
            Throw New IndexOutOfRangeException()
        End If

        Select Case CStr(ComboBoxEncoding.SelectedItem)
            Case "ASCII"
                Return System.Text.Encoding.ASCII
            Case Else
                Return System.Text.Encoding.Default
        End Select

    End Function

Thanks man that worked

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.