Computing.Net > Forums > Programming > Vb .net saving file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Vb .net saving file

Reply to Message Icon

Name: karahim
Date: January 31, 2005 at 19:09:50 Pacific
OS: Windows 2000
CPU/Ram: AMD Athlon 512MB
Comment:

I am new to VB .NET. I am trying to select a file and saving it with another name, but file is not being saved with new name. Kindly advise. The code is:
Private Sub btnOpenFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenFile.Click
OpenFileDialog1.InitialDirectory = "c:\"
OpenFileDialog1.Title = "Select a File"
OpenFileDialog1.Filter = "Text Files|*.txt"
OpenFileDialog1.FilterIndex = 1
If OpenFileDialog1.ShowDialog() <> DialogResult.Cancel Then
txtSource.Text = OpenFileDialog1.FileName
Else
txtSource.Text = ""
End If

End Sub

Private Sub btnSaveFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveFile.Click
SaveFileDialog1.Title = "Specify Destination Filename"
SaveFileDialog1.Filter = "Text Files|*.txt"
SaveFileDialog1.FilterIndex = 1
SaveFileDialog1.OverwritePrompt = True
SaveFileDialog1.CreatePrompt = True
If SaveFileDialog1.ShowDialog() <> DialogResult.Cancel Then
txtDestination.Text = SaveFileDialog1.FileName

End If

End Sub


karahim



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: January 31, 2005 at 22:50:37 Pacific
Reply:

There is nothing in your code that actually saves a file, or opens it for that matter. All you have is two functions to select two different files.

You need to do something with txtSource.Text and txtDestination.Text which are just two text boxes with filenames in them.

You would probably be better just using the Copy command to copy the source to the destination.

Stuart


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Vb .net saving file

VB 2005 Save File Dialog www.computing.net/answers/programming/vb-2005-save-file-dialog/14017.html

VB.NET Open files and Create Email www.computing.net/answers/programming/vbnet-open-files-and-create-email/3125.html

vb.net enumerate files from folder www.computing.net/answers/programming/vbnet-enumerate-files-from-folder/14728.html