Equivalent to "Open filename for output as # 1" from VB6 to .NET

Another issue of migration,

I have another piece of VB6 code that seems to need a workaround for .NET. For the shortened version, this is all it does:

Open sFileName For Output As #1 Print #1, Print #1, "Facility:" & vbTab & Replace(Frame1.Caption, ",", " ") Print #1, Print #1, "Address:" & vbTab & Replace(Me.lblAddr1.Caption, ",", " ") Print #1, "City/State:" & vbTab & Replace(Me.lblAddr2.Caption, ",", " ") 

And so on and so forth. You can see that it keeps repeating in order to create new lines. The question is, how do I implement the same thing in .NET? Thanks for helping everyone.

Logan

+4
source share
1 answer
  Imports System Imports System.IO Imports System.Text Imports System.Collections.Generic Class Program Public Shared Sub Main(ByVal args As String()) Dim mydocpath As String = _ Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) Dim sb As New StringBuilder() For Each txtName As String _ In Directory.EnumerateFiles(mydocpath, "*.txt") Using sr As New StreamReader(txtName) sb.AppendLine(txtName.ToString()) sb.AppendLine("= = = = = =") sb.Append(sr.ReadToEnd()) sb.AppendLine() sb.AppendLine() End Using Next Using outfile As New StreamWriter(mydocpath & "\AllTxtFiles.txt", Encoding.Default) outfile.Write(sb.ToString()) End Using End Sub End Class 

http://msdn.microsoft.com/en-us/library/6ka1wd3w.aspx#Y0

+7
source

Source: https://habr.com/ru/post/1400910/


All Articles