Get Filename FROM path

clemboclembo Member Posts: 122
I have a function that get a path for a file. I want to extract Filename from path. How can I do it? There is a function or I need to build one?

Comments

  • Yaroslav_GaponovYaroslav_Gaponov Member Posts: 158
    Hi

    You just can use an Automation 'Windows Script Host Object Model'.FileSystemObject and function GetFileName :D

    or like this I hope

    strFilename := strcpy(strFile,strlen(strPath)+1);
  • fufikkfufikk Member Posts: 104
    Or find the last '\' and copy everything after that. If there's no '\' then the entire path is filename.
  • fverkelfverkel Member Posts: 66
    FileTxt := PathAndFileTxt;
    WHILE STRPOS(FileTxt, '\') <> 0 DO
      FileTxt := COPYSTR(FileTxt, 1 + STRPOS(FileTxt, '\'));
    
    Keep It Simple and Stupid (KISS), but never oversimplify.
Sign In or Register to comment.