xsharp.eu • FileInfo:Stem?
Page 1 of 1

FileInfo:Stem?

Posted: Mon Feb 17, 2020 2:28 pm
by FFF
Probably i don't see the obvious, but i can't find an access to "FileInfo" for the "stem"-part of the path, i.e. for
D:MyFile.txt
the "MyFile" part.
There's extension, directoryname, fullname, but no "stem" :(

FileInfo:Stem?

Posted: Mon Feb 17, 2020 4:04 pm
by wriedmann
Hi Karl,
its seems so....
Maybe you have to write that yourself....

Code: Select all

static method GetFilenameFromPath( cFullPath as string ) as string
	local nPos				as int
	local cReturn			as string

	if ( nPos := cFullPath:LastIndexOf( Path.DirectorySeparatorChar ) ) <= 0
		cReturn				:= cFullPath
	else
		if cFullPath:Length > ( nPos + 1 )
			cReturn				:= cFullPath:Substring( nPos + 1 )
		else
			cReturn				:= ""
		endif
	endif

	return cReturn
And then retrieve the extension, get the relative length and use only the left x characters.
Wolfgang

FileInfo:Stem?

Posted: Mon Feb 17, 2020 4:06 pm
by robert
Karl,

System.IO.Path.GetFileNameWithoutExtension()

Robert

FileInfo:Stem?

Posted: Mon Feb 17, 2020 4:15 pm
by FFF
Robert,
thx, works. But why the didn't add the access, (using this call) is beyond me ;)