我用OpenDialog打开一个文件
然后用Edit控件显示打开的文件名假设显示的为:d:\my document\1.wav请问我怎么把1.wav取出来呀,我气风了我!

解决方案 »

  1.   

    if Opendialog.execute then
       showmessage(opendialog.filename);
      

  2.   

    yzykjh(FishMan)说的对呀,就是这样的,
      

  3.   

    用extractfilename('d:\my document\1.wav')
      

  4.   

    ExpandFileName() 返回文件的全路径(含驱动器、路径) 
    ExtractFileExt() 从文件名中抽取扩展名 
    ExtractFileName() 从文件名中抽取不含路径的文件名 
    ExtractFilePath() 从文件名中抽取路径名 
    ExtractFileDir() 从文件名中抽取目录名 
    ExtractFileDrive() 从文件名中抽取驱动器名 
    ExpandUNCFileName() 返回含有网络驱动器的文件全路径 
    ExtractRelativePath() 从文件名中抽取相对路径信息 用OpenDialog.FileName做参数
      

  5.   

    showmessage(extractFilename(opendialog.filename));
      

  6.   

    要播放它吗?
    uses mmsystem;if opendialog1.Execute then
        playSound(pchar(opendialog1.FileName),0,0);
      

  7.   

    哦,不好意思,大家误会我的意思了。我的意思是说:文件名显示为字符串:d:\my document\1.wav之后
    我不要前面的d:\my document\
    我只要1.wav,请问怎么实现??谢谢大家的积极参与!
      

  8.   

    用extractfilename('d:\my document\1.wav')就可以
      

  9.   

    var
       temchar,temstr:string;
       i:integer;
    begin
       temstr:='';
       for i:=length(edit1.text) downto 1 do
       begin
           temchar:=edit1.text[i];
           if not (temchar='\') then temstr:=temstr+temchar;
       end;temstr就是1.wav
      

  10.   

    在激发opendialog1的事件中加入如下代码:
     if opendialog1.Execute then
         edit1.Text :=extractfilename(opendialog1.FileName);