我猜想问题可能在这里
FileExists(ExtractFilePath(Application.ExeName) + '\DataBase\tsglxt.mdb')
我刚才测试了一下,ExtractFilePath(Application.ExeName)返回的字符串后面已经多了一个\,然后你这里有加了一个\,那么可能就是:
E:\Program Files\Borland\Delphi6\Projects\\DataBase\tsglxt.mdb,这个当然是错误的。

解决方案 »

  1.   

    谢谢,我试试看,不过

    ShowMessage(ExtractFilePath(Application.ExeName) + '\DataBase\tsglxt.mdb')的时候是对的啊,没有多啊;
    我再看一看;
    谢谢:)
      

  2.   

    ExtractFilePath(paramstr(0)+'DataBase\'+ 'tsglxt.mdb';
      

  3.   

    ExtractFilePath(paramstr(0))+'DataBase\'+ 'tsglxt.mdb';
      

  4.   

    if FileExists(ExtractFilePath(Application.ExeName) + 'DataBase\tsglxt.mdb') then
      begin
        if DeleteFile(ExtractFilePath(Application.ExeName) + 'DataBase\tsglxt.mdb') then
        Application.MessageBox(PChar('成功删除文件!!!'),'反馈信息',MB_Ok+MB_ICONINFORMATION);
      end;
    为什么还不显示?
      

  5.   

    应该这样:
    if FileExists(ExtractFilePath(Application.ExeName) + 'DataBase\tsglxt.mdb') then
      begin
        if DeleteFile(ExtractFilePath(Application.ExeName) + 'DataBase\tsglxt.mdb') then
        Application.MessageBox(PChar('成功删除文件!!!'),'反馈信息',MB_Ok+MB_ICONINFORMATION);
    或者:
    if FileExists(ExtractFileDir(Application.ExeName) + '\DataBase\tsglxt.mdb') then
      begin
        if DeleteFile(ExtractFileDir(Application.ExeName) + '\DataBase\tsglxt.mdb') then
        Application.MessageBox(PChar('成功删除文件!!!'),'反馈信息',MB_Ok+MB_ICONINFORMATION);
      

  6.   

    TO chechy(我爱洁洁) 
    为什么还是删除不了呢?这次我去掉了那个了啊;就像上边的一样;
    对了,那个目录下还有一个Access.LockFile.9,是不是有它在,就不能删除了呢?我应该如何办呢?
    如何备份呢?
      

  7.   

    就比如正在运行的exe无法删除一样,有些文件一旦打开,在没有关闭前是不能删除的。
    如果你删除的mdb文件是你正在打开的,那么就没法删除。
      

  8.   

    嘻嘻,这个问题嘛,嘻嘻,我再试一试看可不可以;
    临时文件是在你打开access时才有的,并不是运行程序是有的,记住啦;
    嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻
    procedure Tm_Mainform.N17Click(Sender: TObject);
    var
      DataBaseName,
      ConnectStr:ansiString;
      RationDataBaseName : AnsiString;
    begin
      DataBaseName := GetCurrentDir + '\DataBase\tsglxt.mdb';
      DataModule2.tsglxtADOConnection.Connected:=false;
      DataModule2.tsglxtADOConnection.ConnectionString:='';
      OpenDialog1.InitialDir := ExtractFilePath(Application.ExeName) + '数据库备份';
      if FileExists(DataBaseName) then
      begin
        if DeleteFile(DataBaseName)then
        begin
          Application.MessageBox('对不起,数据库恢复错误,请您重新进行操作','错误提示',MB_OK + MB_ICONINFORMATION);
          Exit;
        end;
        Application.MessageBox('对不起,数据库恢复错误,请您重新进行操作','错误提示',MB_OK + MB_ICONINFORMATION);
        Exit;
      end;
      if OpenDialog1.Execute then
      begin
        if Not CopyFileTo(ChangeFileExt(OpenDialog1.FileName,'' ) + '.mdb', DataBaseName) then
        begin
          Application.MessageBox('对不起,数据库恢复错误,请您重新进行操作','错误提示',MB_OK + MB_ICONINFORMATION);
          Exit;
        end;
      end else
      begin
        Application.MessageBox('对不起,数据库备份错误,请您重新进行操作','操作失败提示',MB_OK + MB_ICONINFORMATION);
        Exit;
      end;
      ConnectStr:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+DataBaseName+';';
      DataModule2.tsglxtADOConnection.Connected:=false;
      DataModule2.tsglxtADOConnection.ConnectionString:='';
      DataModule2.tsglxtADOConnection.ConnectionString:=ConnectStr+'Persist Security Info=true';
      DataModule2.tsglxtADOConnection.Connected:=true;
    end;
    嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻
      

  9.   

    不要ChangeFileEx,CopyFileTo(OpenDialg1.File,Application.ExeName)
      

  10.   

    不要ChangeFileEx,CopyFileTo(OpenDialg1.File,ExtractFilePath(Application.ExeName)+'DataBase\tsglxt.mdb')