delphi 分离路径中的路径和文件名

//   包括文件名的路径名中分离出目录名和文件名.  
  function   MPathAndFile(const   strFull:   String;   var   strPath,   strName:   String):   Boolean;  
  var  
      iCnt,   iPos     :   Integer;  
  begin  
      iPos   :=   -1;  
      for   iCnt   :=   1   to   Length(strFull)   do   begin  
          if   strFull[iCnt]   =   ‘\’   then   iPos   :=   iCnt;  
      end;  
      if   iPos   <>   -1   then   begin  
          strPath   :=   Copy(strFull,   1,   iPos);  
          strName   :=   Copy(strFull,   iPos+1,   Length(strFull)-iPos);  
          Result   :=   True;  
      end  
      else   Result   :=   False;  
  end;  
   
  ////////////////////////////////////////////////////////////////////////  
  //   从文件名中分离出名称和扩展名.  
  function   MNameAndExt(const   strFull:   String;   var   strName,   strExt:   String):   Boolean;  
  var  
      iCnt,   iPos     :   Integer;  
  begin  
      iPos   :=   -1;  
      for   iCnt   :=   1   to   Length(strFull)   do   begin  
          if   strFull[iCnt]   =   ‘.’   then   iPos   :=   iCnt;  
      end;  
      if   iPos   <>   -1   then   begin  
          strName   :=   Copy(strFull,   1,   iPos-1);  
          strExt   :=   Copy(strFull,   iPos+1,   Length(strFull)-iPos);  
          Result   :=   True;  
      end  
      else   Result   :=   False;  
  end;



发表评论

您的电子邮箱地址不会被公开。

63 + = 65