08-02-2012, 12:17 PM
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]
[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.");
System.out.println("I prefer Java.");