Hello,
I'm working on a VB project, and I'm trying to use the Savefiledialog
boxes so that users can... well save files, but i want to send the name
of the file that they are saving to a text file. Just the name, not
filepath
EX:
i want it to send:
name.txt
But it sends:
C:/somedirs/name.txt
The code that I'm using is
If Me.SaveFileDialog1.ShowDialog() = DialogResult.OK Then
Dim sw As StreamWriter = New StreamWriter("In_Use.stk")
sw.WriteLine(SaveFileDialog1.FileName)
sw.Close()
end if
(using)
Imports System
Imports System.IO
Any help is greatly appreciated
Thanks so much
-Robert

Windows SaveFileDialogs
Eric1965
That function call just wrapped in a function name which is possibly a little more descript. Try chnaging the string s representing the filename and you'll see the behaviour.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String = "c:\test1\test.xls"
MsgBox(GetJustFileName(s))
End Sub
Function GetJustFileName(ByVal Path As String) As String
Return System.IO.Path.GetFileName(Path)
End Function
End Class
imLex
hguo98
Hi,
Check out the Path class. Path.GetFileName() should work for you.
http://msdn2.microsoft.com/en-us/library/system.io.path.getfilename.aspx
Regards,
Mike