1
텍스트 파일의 특정 줄을 다른 텍스트 파일로 추출하려고합니다. 내가 다음 코드특정 텍스트 파일의 특정 줄을 다른 텍스트 파일로 추출
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Tr As IO.TextReader = System.IO.File.OpenText("C:\Assignment.txt")
For c As Integer = 1 To 10
If c = 7 Then
Dim MyFileLine As String = Split(Tr.ReadToEnd(), vbCrLf)(c) & vbCrLf
Tr.Close()
Dim TW As System.IO.TextWriter
'Create a Text file and load it into the TextWriter
TW = System.IO.File.CreateText("C:\Assignment1.txt")
TW.WriteLine(MyFileLine)
'Flush the text to the file
TW.Flush()
'Close the File
TW.Close()
End If
Next c
End Sub
End Class
그러나이 코드 추출물만을 줄 내가 8, 9, 10, 14, 15, 16를 추출 할 아무 7을 사용하고, 또한 라인. 제게 올바른 해결책을 알려주세요. 미리 감사드립니다.
No .... (현재 줄 = Tr.ReadLine()) 없음 Nothing –
코드를 변경하고 나중에'TextReader '를 지우기 위해'Using' 문을 구현했습니다. 죄송합니다, C#에서 변환! – XN16
좋아, 이제 다른 문제로하자. ,, 특정 HTML 페이지의 특정 줄을 복사하려면 어떤 코드를 써야 하나? –