Forum > General

mac - If FileExists(fileName) always returns false

(1/3) > >>

CaptBenB:
newbie question... I have looked all day yesterday and today... but can't seem to figure this out.  any help is appreciated.

procedure TForm1.FormActivate(Sender: TObject);
var
  fileName: string;
  answer: boolean;
begin

  fileName := 'test';  // -- this file exists
  answer:=FileExists(fileName);

  If answer=True Then  showmessage('True');
  If answer=False Then  showmessage('False');
end

BSaidus:
try to use the full path to the file.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  filename = IncludeTrailingPathDelimiter(GetCurrentDir()) + 'test';  answer:=FileExists(fileName);   If answer=True Then  showmessage('True');  If answer=False Then  showmessage('False'); 

CaptBenB:
Good idea... but still the same result.

lainz:
Remember that's macOS, and files are considered to be inside the app bundle by default.

To access external files you must include the full path.

dsiders:

--- Quote from: lainz on June 15, 2024, 12:06:38 am ---Remember that's macOS, and files are considered to be inside the app bundle by default.

To access external files you must include the full path.

--- End quote ---

I would absolute to that requirement. There's also permissions to consider (it is Unix after all). Case. Phase of the moon. And Tim Cook's shoe size.

Navigation

[0] Message Index

[#] Next page

Go to full version