08-02-2012, 10:29 AM
Hey, I was just wondering how to get the actual fine name(not including the path) of a file chosen from a save file dialog. If anyone knows, help would be much appreciated! thanks!
getting a file name form a save dialoge
|
08-02-2012, 10:29 AM
Hey, I was just wondering how to get the actual fine name(not including the path) of a file chosen from a save file dialog. If anyone knows, help would be much appreciated! thanks!
08-02-2012, 10:40 AM
Do you mean like finding the actual file of your program inside your computer files?
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]
Also known as Rocketalypse.
System.out.println("I prefer Java."); |
« Next Oldest | Next Newest »
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Rename application file | brco900033 | 3 | 14,838 |
10-15-2013, 12:03 AM Last Post: brandonio21 |
|
I am getting problem with brandonio's registration form... | mnxford | 1 | 9,168 |
03-27-2013, 10:55 AM Last Post: mnxford |
|
i am getting a problem with brandonio's login form | mnxford | 1 | 9,098 |
03-27-2013, 10:55 AM Last Post: mnxford |
|
Copy file to clipboard | brco900033 | 4 | 17,367 |
11-04-2012, 12:17 AM Last Post: brandonio21 |
|
How do I fill my form with MySQL data based on Combobox? | kismetgerald | 8 | 26,702 |
10-14-2012, 09:05 PM Last Post: brandonio21 |
|
Save Help | manishshrestha60 | 2 | 11,542 |
09-14-2012, 11:48 PM Last Post: Vinwarez |
|
External Settings File | brco900033 | 1 | 8,772 |
11-04-2011, 02:47 PM Last Post: brandonio21 |
|
Form/Application Store | PsychicShadow | 2 | 12,414 |
06-02-2011, 09:16 PM Last Post: xolara |