1 Replies - 265 Views - Last Post: 05 November 2019 - 05:50 AM Rate Topic: -----

#1 aishwarya.sony   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-November 19

Need to encode in ASCII format from one text file & decode in new

Posted 05 November 2019 - 05:29 AM

Hi Team,

I am new to VB.Net and have been learning it from past 2 days.

I was trying to finish a assignment that was created by me,but now I am stuck in between.

1. Take a Text File with multiple lines of text as input (Example : ExistingTextFile.txt)
2. Create newTextFile.txt in same location
3. Encode the content of ExistingTextFile.txt (ASCII + 3) and write it to NewTextFile.txt
4. Read NewTextFile.txt, decode it and display it
5. Update the ExistingTextFile with Date and Time

The code which I am able to do:

Public Class Form1
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

Using fold As New OpenFileDialog

If fold.ShowDialog() = DialogResult.OK Then

fold.RestoreDirectory = True
MessageBox.Show("You selected " & fold.FileName)
TextBox1.Text = fold.FileName


End If
End Using
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim fold As String
Dim Text As String
Text = My.Computer.FileSystem.ReadAllText(TextBox1.Text, System.Text.Encoding.UTF8)

MsgBox(Text)

Dim Newfilepath As String = "C:\Users\xsbhangaai\Desktop\visualbasic\New Text File.txt"
If Not System.IO.File.Exists(Newfilepath) Then
System.IO.File.Create(Newfilepath)
MsgBox("New Text file has Created")
Else
MsgBox("New Text file has already exists in the same location")
End If
End Sub
End Class

I am able to open a text file and read it, but unable to encode it in ASCII format and later decode it in new text file.
Can someone help?

Is This A Good Question/Topic? 0
  • +

Replies To: Need to encode in ASCII format from one text file & decode in new

#2 maceysoftware   User is offline

  • Member Title
  • member icon

Reputation: 394
  • View blog
  • Posts: 1,648
  • Joined: 07-September 13

Re: Need to encode in ASCII format from one text file & decode in new

Posted 05 November 2019 - 05:50 AM

Seems like you want the Encoding.ASCII Namespace.

Read through the link and get back to us if you have any other questions? But currently your question isn't asking one question but rather than how do I do it.

Regards
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1