הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Sunday, February 20, 2011 1:51 PM
Dim file5 As String
Dim save As New SaveFileDialog
file5 = Path.GetFileName(save.FileName)
Dim file6 As String = Path.GetFileNameWithoutExtension(save.FileName)
Dim filepath As String
filepath = save.FileName.Remove(Val(save.FileName.Length) - Val(file5.Length), Val(save.FileName.Length)) + file6
TextBox1.Text = filepath
In my theory, this would work but I got this error:
Error: Index and count must refer to a location within the string.
Parameter name: count
I'm trying to remove the extension from the Filename of the SaveFileDialog, is there a simpler way?
All replies (2)
Sunday, February 20, 2011 4:41 PM ✅Answered | 1 vote
A simple example of using these functions to get to your desired goal.
Dim save As New SaveFileDialog
If save.ShowDialog() <> DialogResult.Cancel Then
TextBox1.Text = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(save.FileName), System.IO.Path.GetFileNameWithoutExtension(save.FileName))
End If
Sunday, February 20, 2011 2:29 PM
Use the IO Path class, it has all kind of methods to get everything from a filename
http://msdn.microsoft.com/en-us/library/system.io.path.aspx
Success
Cor