Lazarus
Free Pascal => Beginners => Topic started by: JLWest on November 24, 2020, 02:23:50 am
Title:
(Solved)Fileutil
Post by:
JLWest
on
November 24, 2020, 02:23:50 am
Code: Pascal
[Select]
[+]
[-]
Var
AFile
,
ADir
:
String
;
Item
:
String
=
'C:\My Dir\MyFile.txt'
;
AFile
:
=
ExtractFileNameWithoutExt
(
Item
)
;
===
> Returns
'C:\My Dir\MyFile
ADir := ExtractShortPathNameUTF8( Item ); ===> Returns '
C
:
\My Dir\MyFile
.
txt
'
i was think ExtractFileNameWithoutExt would return 'MyFile' with out the path and
ExtractShortPathNameUTF8 would return 'My Dir'
Title:
Re: Fileutil
Post by:
jamie
on
November 24, 2020, 04:25:48 am
Try something like this
Name := ExtraFileName(ExtraFileNameWithoutPath(TheName));
Title:
Re: Fileutil
Post by:
JLWest
on
November 24, 2020, 05:44:43 am
Thanks,
That would be equal to:
Var AFileName : String = 'Nameofile.exe';
Name : String
begin
Name := Copy2Symb( AFileName, '.' );
end;
Result := 'Nameoffile'
Title:
Re: Fileutil
Post by:
Bart
on
November 24, 2020, 12:56:11 pm
Didn't we have an ExtractFilenameOnly() function somewhere?
Bart
Title:
Re: Fileutil
Post by:
Sieben
on
November 24, 2020, 01:51:37 pm
In LazFileUtils...
Title:
Re: Fileutil
Post by:
JLWest
on
November 24, 2020, 09:38:52 pm
@Bart You are right
There is a message in the message box saying:
unit1.pas(1160,17) Warning: Symbol "ExtractFileNameWithoutExt" is deprecated: "
Use the function from unit LazFileUtils"
function ExtractFileNameOnly(const AFilename : string) : string;
If it's Green I go I don't read those pesky messages, maybe I should.
Title:
Re: Fileutil
Post by:
Bart
on
November 24, 2020, 10:14:29 pm
Quote from: JLWest on November 24, 2020, 09:38:52 pm
If it's Green I go I don't read those pesky messages, maybe I should.
Yes, you should.
At some point the deprecated function will be removed, et voila, after you upgraded it won't compile anymore O:-)
Bart
TinyPortal
© 2005-2018