Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getting a file name form a save dialoge
#3
I wrote a small application for saving a file. Here is the code:
[code2=vbnet]Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SaveFile As New SaveFileDialog
SaveFile.Title = "Save file"
SaveFile.Filter = "Text files (*.txt)|*.txt"
SaveFile.InitialDirectory = "C:\"
SaveFile.RestoreDirectory = True
Dim d = SaveFile.ShowDialog()

If d = DialogResult.OK Then
Try
Dim DocumentTitle As String = System.IO.Path.GetFileName(SaveFile.FileName)
Me.Text = DocumentTitle & " - Software Name"

Dim W As New System.IO.StreamWriter(SaveFile.FileName)
W.Write(RichTextBox1.Text)
W.Close()
Catch ex As Exception
MessageBox.Show("You have encountered an error." & Environment.NewLine & Environment.NewLine & "ERROR: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
End Class[/code2]

Since you don't need that, here is the line that you need:
[code2=vbnet]Dim DocumentTitle As String = System.IO.Path.GetFileName(SaveFile.FileName)
Me.Text = DocumentTitle & " - Software Name"[/code2]
Also known as Rocketalypse.
System.out.println("I prefer Java.");


Messages In This Thread
Re: getting a file name form a save dialoge - by Vinwarez - 08-02-2012, 12:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rename application file brco900033 3 14,841 10-15-2013, 12:03 AM
Last Post: brandonio21
  I am getting problem with brandonio's registration form... mnxford 1 9,171 03-27-2013, 10:55 AM
Last Post: mnxford
  i am getting a problem with brandonio's login form mnxford 1 9,099 03-27-2013, 10:55 AM
Last Post: mnxford
  Copy file to clipboard brco900033 4 17,374 11-04-2012, 12:17 AM
Last Post: brandonio21
  How do I fill my form with MySQL data based on Combobox? kismetgerald 8 26,709 10-14-2012, 09:05 PM
Last Post: brandonio21
  Save Help manishshrestha60 2 11,543 09-14-2012, 11:48 PM
Last Post: Vinwarez
  External Settings File brco900033 1 8,776 11-04-2011, 02:47 PM
Last Post: brandonio21
  Form/Application Store PsychicShadow 2 12,421 06-02-2011, 09:16 PM
Last Post: xolara

Forum Jump:


Users browsing this thread: 1 Guest(s)