如题

解决方案 »

  1.   

    没人帮忙吗,就是如何用字符串构造TFileName类型
      

  2.   

    type TFileName = type string;str := FileName就行
      

  3.   

    TFileName is a string that represents a file name.UnitSysUtilsDelphi syntax:type TFileName = type string;C++ syntax:typedef AnsiString TFileName;DescriptionUse TFileName to represent strings that are only used for file names.是帮助里的
      

  4.   

    str := FileName这行可以解释一下吗
    比如我要载入test.doc这个文件
    要如何写代码
    type TFileName = type string;写在type定义里
    事件中写str:='test.doc'
    OleContainer1.CreateObjectFromFile(str,False);
    这样出错!!!!!
      

  5.   

    delphi TFileName 类型就是 String 类型.
    不需要定义,直接用就行.
    str := 'test.doc';
    CreateObjectFromFile(str,False);
      

  6.   

    上面是
    OleContainer1.CreateObjectFromFile(str,False);
      

  7.   

    不行啊
    OleContainer1.CreateObjectFromFile(str,False);
    这样写会出错
    如果加个OpenDialog
    if OpenDialog1.Execute then
      OleContainer1.CreateObjectFromFile(OpenDialog1.FileName,False);
    这样就可以了
    看来还是要用TFileName类型
      

  8.   

    看SysUtil中的定义就知道了{ Generic filename type }  TFileName = type string;
      

  9.   

    我说的str 是一个文件的全路径
      

  10.   

    先把后边的文件名截取出来使用:TFileName(截到的文件名)
      

  11.   

    TFilename就是string,不过在使用时,要考虑它是否带有路径信息