Hello, good day, I just need some help here, I have found n the net this line of codes here:
The purpose of this code is to copy a certain file and save it to another directory using open and save dialog, this code works well but I what I want to be done is that after selecting the file that I want to copy it will be just automatically saved into the specific directory that I set wherein it will be named according to what I set also in the code. Say for example I want to copy the file named MyTxt.txt and once I select this file it will be automatically saved in C:\MyFiles as MyFile.txt. I spend my whole day today just to figure out how to make this but still no good. Thanks to someone who can help me out.
VB.NET:
Using openDialog As New OpenFileDialog()
openDialog.CheckFileExists = True
openDialog.CheckPathExists = True
openDialog.Filter = "Text Document (*.txt)|*.txt"
Using saveDialog As New SaveFileDialog()
saveDialog.CheckFileExists = False
saveDialog.CheckPathExists = True
saveDialog.FileName = ("MyFile") & ".txt"
saveDialog.Filter = "Text Document (*.txt)|*.txt"
Try
If openDialog.ShowDialog() = Windows.Forms.DialogResult.OK AndAlso saveDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
IO.File.Copy(openDialog.FileName, saveDialog.FileName, True)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Using
End Using