Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do can this IO work?

Status
Not open for further replies.

Shaun29

Programmer
Oct 22, 2008
53
US
basically I am trying to use the selected file in open dialog to write to instead of a pre-ordained "logfile"

i want to select the file to write to?


Me.txtFile.Text = ""
ofd.ShowDialog()
Me.txtFile.Text = ofd.FileName

If Not Me.txtFile.Text = "" Then
'Read the existing file
Dim FileText As String = ""
FileText = System.IO.File.ReadAllText(Me.txtFile.Text)
'Write to the log file
System.IO.File.AppendAllText(LogFile,FileText)

Timer1.Start()
Timer1.Enabled = True


MessageBox.Show("B.O.M Transfered")
Else
MessageBox.Show("Please select a file.")


how do i implement the selected file in open file dialog instead of this..
System.IO.File.AppendAllText(LogFile,FileText)

i need

System.IO.File.AppendAllText(what ever file is selected from open file dialog)

 
Are you saying you want to choose a source file with the OpenFileDialog and then choose a destination file? If so, just reuse the OpenFileDialog and the .FileName property instead of your LogFile variable.
 
can you give me an example
System.IO.File.AppendAllText(Filename)???
 
i tryed this but it does no work

System.IO.File.AppendAllText(ofd.FileName, FileText)
 
every time i use
System.IO.File.AppendAllText(ofd.FileName, FileText)
it writes text to the file i first selected
 
What does it do? Are you using two different strings, or re-appending the same string from the same file?
 
i just ws using on open file dialog i just added another on and got it to work.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top