'対象のファイル Dim fileName As String = "C:\vb\test.csv" '対象ファイルを別名(newFileName)に変更 Dim newFileName As String = IO.Path.ChangeExtension(fileName, "rename.csv") IO.File.Move(fileName, newFileName) 'newFileNameから1行ずつ読んで fileNameに書き込んでいく。 Using reader As New IO.StreamReader(newFileName) Using writer As New IO.StreamWriter(fileName, False) Do Until reader.EndOfStream '行数 Dim lineCount As Integer lineCount += 1 Dim line As String = reader.ReadLine If lineCount = 1850 Then '1850行目だけはLabel1.Textを書き込む。 writer.WriteLine(Label1.Text) Else writer.WriteLine(line) End If Loop End Using End Using '別名(newFileName)で保存したファイルを削除 IO.File.Delete(newFileName)