VB.NET中如何实现将文件名作为输出参数打开?
- 内容介绍
- 文章标签
- 相关推荐
本文共计273个文字,预计阅读时间需要2分钟。
另一个移动问题,我有一块VB6代码,似乎需要.NET的一些解决方案。对于短版本,这就是它所做的一切:+Open+sFileName For Output As+
我有另一块VB6代码,似乎需要.NET的一些解决方法.对于缩短版本,这就是它所做的一切:
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, ",", " ")
等等等等.你可以看到它不断重复创建新的线条.问题是,我如何在.NET中实现相同的功能?感谢所有帮助人员.
洛根
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
msdn.microsoft.com/en-us/library/6ka1wd3w.aspx#Y0
本文共计273个文字,预计阅读时间需要2分钟。
另一个移动问题,我有一块VB6代码,似乎需要.NET的一些解决方案。对于短版本,这就是它所做的一切:+Open+sFileName For Output As+
我有另一块VB6代码,似乎需要.NET的一些解决方法.对于缩短版本,这就是它所做的一切:
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, ",", " ")
等等等等.你可以看到它不断重复创建新的线条.问题是,我如何在.NET中实现相同的功能?感谢所有帮助人员.
洛根
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
msdn.microsoft.com/en-us/library/6ka1wd3w.aspx#Y0

