我要把打开的文件名送到listbox里面去,但是得到的是有路径的,怎么才能只要文件名啊!!
listbox1.items.add(opendialog1.filename);????

解决方案 »

  1.   

    listbox1.items.add(ExtractFileName(opendialog1.filename));
      

  2.   

    用extractfilename这个函数就可以了
    listbox1.items.add(extractfilename(opendialog1.filename))
    这样就可以实现你所说的要求了
      

  3.   

    Extracts the name and extension parts of a file name. UnitSysUtilsCategoryfile name utilitiesDelphi syntax:function ExtractFileName(const FileName: string): string;C++ syntax:extern PACKAGE AnsiString __fastcall ExtractFileName(const AnsiString FileName);DescriptionThe resulting string is the rightmost characters of FileName, starting with the first character after the colon or backslash that separates the path information from the name and extension. The resulting string is equal to FileName if FileName contains no drive and directory parts.Note: This function works for multi-byte character systems (MBCS).