Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

File open for input and output vb.net

Posted on 2009-04-01
2
Medium Priority
?
2,032 Views
Last Modified: 2012-05-06
In VB6 I could open a file for input then open a file for output and then write any part of a line from the input file to the output file see sample below.  

I want to do exactly the same thing in vb.net,  I have found example which show me how to read a file and write static text to a file but I can not find any help on how to write a string from the file I just opened and read.

Any help greatlt appreciated.
Private Sub Form_Load()
 
Open "C:\Users.ini" For Input As #1
Open "C:\StationID.ini" For Input As #2
 
 
Do While EOF(2) = False And EOF(1) = False
Open "C:\Config.NT" For Output As #3
Line Input #2, Temp1$
Print #3, "dos = high, umb"
Print #3, ";device=%SystemRoot%\system32\himem.sys"
Print #3, ";device=%SystemRoot%\system32\emm386.exe"
Print #3, "EMM =RAM"
Print #3, "FILES=80"
Print #3, "device=C:\utils\netid.exe /d:" & Temp1$
Print #3, ""
Print #3, "REM Added by Pervasive.SQL V8 install:"
Print #3, "DEVICE=C:\PVSW\BIN\BTRDRVR.SYS"
 
Close #3
 
Line Input #1, Temp$
FileSystem.MkDir "C:\WorkStationIDs\" & Temp$
 
FileSystem.FileCopy "C:\Config.NT", "C:\WorkStationIDs\" & Temp$ & "\Config.NT"
Loop
 
 
Unload Me
 
End Sub

Open in new window

0
Comment
Question by:smasshed
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 2000 total points
ID: 24040184
In .NET you can use StreamReader and StreamWriter to do that!
Example:

        Dim fileName As String = "d:\test.txt"
        Dim fileNameOutput As String = "d:\testOutput.txt"
 
        Using writer As New IO.StreamWriter(fileNameOutput)
 
            Using reader As New IO.StreamReader(fileName)
 
                While Not reader.EndOfStream()
                    Dim result As String = reader.ReadLine()
                    writer.WriteLine(result & " some extra text")
                End While
 
            End Using
 
        End Using

Open in new window

0
 
LVL 1

Author Closing Comment

by:smasshed
ID: 31565338
Easy when you know how, thanks alot.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question