Path: GetFileNameWithoutExtension |
Returns the filename portion of a path without the filename extension.
Public Function GetFileNameWithoutExtension( ByRef Path As String ) As String
This function does not verify that the path or file exists.
Exception | Condition |
---|---|
ArgumentException | Path contains one or more of the invalid characters defined in GetInvalidPathChars. |
The following code example demonstrates a use of the GetFileNameWithoutExtension method.
Public Sub Main() Const FileName As String = "C:\MyDir\MyFile.Ext" Const PathName As String = "C:\MyDir\" Dim Result As String Result = Path.GetFileNameWithoutExtension(FileName) Debug.Print CorString.Format("GetFileNameWithoutExtension('{0}') returns '{1}'", FileName, Result) Result = Path.GetFileNameWithoutExtension(PathName) Debug.Print CorString.Format("GetFileNameWithoutExtension('{0}') returns '{1}'", PathName, Result) End Sub ' This example code produces the following output. ' ' GetFileNameWithoutExtension('C:\MyDir\MyFile.Ext') returns 'MyFile' ' GetFileNameWithoutExtension('C:\MyDir\') returns ''