Soru & Cevap

.txt kayıt turunu UTF8 e donusturmek Visual Basic ile ...

25.05.2017 - 10:54

Merhaba basic ile yazdıgım bir programda c:\kasa dizinin altında hesap.txt dosyası varmı yokmu diye kontrol ettiriyorum eğer yoksa oluşturuyorum daha sonra içerisine yazdırmak istediklerimi yazdırıyorum fakat dosya kayıt türü türkce karakterden dolayı işimi görmüyor ANSI olarak kaydediyor.ben dosya kayıt türünün UTF-8 olmasını istiyorum yapamadım belki dosya olustukdan sonra formatını değiştirebilirim diye düşünüyorum.Nasıl bir yol izlemem gerekiyor.Kullandıgım kodlar asagıda.

 

    Dim kasa_fs As System.IO.FileStream = New System.IO.FileStream("C:\kasa\hesap.txt", IO.FileMode.Create)
    Dim kasa_wr As System.IO.StreamWriter = New System.IO.StreamWriter(kasa_fs)

    kasa_wr.Close()

   FileOpen(1, "C:\kasa\hesap.txt", OpenMode.Output)

   PrintLine(1, hesap_kod+ Space(30 - Len(hesap_kod)) + Mid(hesap_ad, 1, 25))

 

24 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user smokietr
smokietr
25.05.2017 - 11:48

Merhaba pek basic tecrübem yok ama yardımcı olmaya çalışayım.

Dim kasa_wr As System.IO.StreamWriter = New System.IO.StreamWriter(kasa_fs)

kısmını

Dim kasa_wr As System.IO.StreamWriter = New System.IO.StreamWriter(kasa_fs, False, Encoding.UTF8)

yada

Dim kasa_wr As System.IO.StreamWriter = New System.IO.StreamWriter(kasa_fs, True, System.Text.Encoding.Default)


şeklinde denermisin ?

Metin Beci
25.05.2017 - 12:07
ikisinde de hata alıyorum Error 15 Overload resolution failed because no accessible 'New' can be called with these arguments: 'Public Sub New(path As String, append As Boolean, encoding As System.Text.Encoding)': Value of type 'System.IO.FileStream' cannot be converted to 'String'. 'Public Sub New(stream As System.IO.Stream, encoding As System.Text.Encoding, bufferSize As Integer)': Value of type 'Boolean' cannot be converted to 'System.Text.Encoding'. 'Public Sub New(stream As System.IO.Stream, encoding As System.Text.Encoding, bufferSize As Integer)': Value of type 'System.Text.Encoding' cannot be converted to 'Integer'.
Metin Beci
25.05.2017 - 12:08
ikisinde de hata alıyorum Error 15 Overload resolution failed because no accessible 'New' can be called with these arguments: 'Public Sub New(path As String, append As Boolean, encoding As System.Text.Encoding)': Value of type 'System.IO.FileStream' cannot be converted to 'String'. 'Public Sub New(stream As System.IO.Stream, encoding As System.Text.Encoding, bufferSize As Integer)': Value of type 'Boolean' cannot be converted to 'System.Text.Encoding'. 'Public Sub New(stream As System.IO.Stream, encoding As System.Text.Encoding, bufferSize As Integer)': Value of type 'System.Text.Encoding' cannot be converted to 'Integer'
Metin Beci
25.05.2017 - 12:09
'Public Sub New(path As String, append As Boolean, encoding As System.Text.Encoding)': Value of type 'System.IO.FileStream' cannot be converted to 'String'. 'Public Sub New(stream As System.IO.Stream, encoding As System.Text.Encoding, bufferSize As Integer)': Value of type 'Boolean' cannot be converted to 'System.Text.Encoding'. 'Public Sub New(stream As System.IO.Stream, encoding As System.Text.Encoding, bufferSize As Integer)': Value of type 'System.Text.Encoding' cannot be converted to 'Integer'