起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 139|回复: 2

【结贴】创建路径**

[复制链接]
发表于 2009-6-9 15:52:32 | 显示全部楼层 |阅读模式
try
    dir:='C:\Documents and Settings\Administrator\Application Data\jserpDownloadedFiles';
    if not sysutils.FileExists(dir) then//如果不存在此路径,则新建一个
    begin
        sysutils.CreateDir(dir);
        //FileSys.FileSystem.CreateDirectory(dir);
    end;
    dir:=dir+'\'
         +self.InfoBroker1.Info.DataSetByID('annex').FieldByName('annexname').asstring ;
    //if self.SaveDialog1.Execute then begin
    //self.fileExistsDown ;
    //if goOnDown =false then exit;
    TBlobField(Self.InfoBroker1.Info.DataSetByID('annex').FieldByName('AnnexContent')).SaveToFile(dir);
    Borland.Delphi.ShellAPI.ShellExecute(0, 'open',PChar(dir), '', '', Borland.Delphi.Windows.SW_SHOW);
    except on e:Exception do
           begin
               jsdialogs.ShowError('查看原始附件的过程中出现了异常,请检查你所要查看的附件是否已经打开或者没有附件对应的打开软件。','错误');
           end;
问题是:比如dir最好组合为:C:\Documents and Settings\Administrator\Application Data\jserpDownloadedFiles\xpcmd.doc
执行到savetofile()时报错:不能创建这个路径
这是我到这个路径下看时xpcmd.doc是个文件夹(没有隐藏扩展名),
还有创建路径的函数,到底是哪一个啊,看bbs上有好几个。并且这个createdir()的返回值总是False。
这个事,搞得我有点晕了,在线等待。谢谢
回复

使用道具 举报

发表于 2009-6-9 16:13:08 | 显示全部楼层
做一个功能,界面上放一个按钮和一个memo1,然后用下面的代码测试看看。
procedure TMainForm.Button1Click(Sender: TObject);
var
  lDir : String;
begin
  lDir := 'C:\Documents and Settings\Administrator\Application Data\jserpDownloadedFiles';
  Dialogs.ShowMessage(lDir);
  if not sysutils.FileExists(lDir) then//如果不存在此路径,则新建一个
  begin
    sysutils.CreateDir(lDir);
  end;
  Memo1.Lines.SaveToFile(lDir + '\a.txt');

end;
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-6-9 16:21:35 | 显示全部楼层
谢谢,结贴吧。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-20 14:42 , Processed in 0.039177 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表