Closed Thread
Results 1 to 4 of 4

Thread: Check if a file exists?

  1. #1
    Lop's Avatar
    Lop
    Lop is offline Speaks fluent binary
    Join Date
    May 2006
    Posts
    1,178
    Rep Power
    30

    Check if a file exists?

    Similar to the C++ thread, how can I check if a file exists in Delphi?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    10
    Rep Power
    0
    It is the FileExists() function.

    Here is a code sample from the help file to check if a file exists and then prompts for confirmation before deleting it:

    Code:
    if FileExists(FileName) then
      if MessageDlg('Do you really want to delete ' + ExtractFileName(FileName) + '?'), mtConfirmation, [mbYes, mbNo], 0, mbNo) = IDYes then 
        DeleteFile(FileName);

  4. #3
    priorityone Guest
    Use FileExists function. If file exists, then this function will return True.

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if FileExists(Edit1.Text) then
    ShowMessage('File already exists!')
    else
    ShowMessage('This file is unique');
    end;

  5. #4
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Exclamation

    Quote Originally Posted by priorityone View Post
    Use FileExists function. If file exists, then this function will return True.

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if FileExists(Edit1.Text) then
    ShowMessage('File already exists!')
    else
    ShowMessage('This file is unique');
    end;
    We appreciate your help, but this issue was solved four months ago in the post above yours. Please try not to bring back dead topics as its not tolerated

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Check if multiple remote files exists HELP! (Using curl)
    By SeanStar in forum PHP Development
    Replies: 7
    Last Post: 12-17-2010, 09:06 AM
  2. Linux/Bash: Check if a file exists
    By Tor in forum Bash / Shell Scripting
    Replies: 4
    Last Post: 07-10-2009, 11:28 AM
  3. Check if a file exists
    By Lop in forum C and C++
    Replies: 4
    Last Post: 08-07-2006, 08:03 PM
  4. Check if a File Exists
    By NeedHelp in forum C# Programming
    Replies: 4
    Last Post: 08-07-2006, 03:20 PM
  5. Check if a URL Exists
    By Chan in forum PHP Development
    Replies: 1
    Last Post: 07-13-2006, 10:54 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts