我想做access数据库的还原,就是在打开文件的时候不知道怎么判断,输入的文件名是否存在啊
各位大虾帮帮忙啊

解决方案 »

  1.   

    文件是否存在 FileExists(FileName)
      

  2.   

    procedure TForm1.Button2Click(Sender: TObject);
    begin
    while true do
    begin
      if OpenDialog1.Execute then
      begin
        if not FileExists(Opendialog1.FileName) then
           Application.MessageBox('文件不存在!!','提示',MB_OK+MB_IconError)
        else
          begin
            Label1.Caption:=Opendialog1.FileName;
            Break;
          end
      end
    else   //按下的是“取消”
      Break;
    end;
      

  3.   

    将OpenDialog1的Options属性中的ofPathMustExist和ofFileMustExist改成True,就可以满足你的要求了