FileInfo:Stem?

This forum is meant for questions and discussions about the X# language and tools
Post Reply
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

FileInfo:Stem?

Post 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" :(
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

FileInfo:Stem?

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

FileInfo:Stem?

Post by robert »

Karl,

System.IO.Path.GetFileNameWithoutExtension()

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

FileInfo:Stem?

Post by FFF »

Robert,
thx, works. But why the didn't add the access, (using this call) is beyond me ;)
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Post Reply