Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Pascal/Delphi

Pascal/Delphi Forum for discussing Borland Delphi and Pascal coding techniques, tips and tricks.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-12-2006, 12:07 PM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,135
Rep Power: 16
Lop is on a distinguished road
Default Check if a file exists?

Similar to the C++ thread, how can I check if a file exists in Delphi?
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 08-15-2006, 09:56 PM
BuildPromoteWin's Avatar   
BuildPromoteWin BuildPromoteWin is offline
Newbie
 
Join Date: Jul 2006
Posts: 10
Rep Power: 0
BuildPromoteWin is on a distinguished road
Default

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);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-06-2007, 05:27 AM
priorityone
Guest
 
Posts: n/a
Default

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;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-07-2007, 12:54 AM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,731
Last Blog:
Passwords
Rep Power: 20
John has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud of
Send a message via AIM to John
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Project: ionFiles - Joomla Simple File Download Jordan Community Projects 302 08-30-2008 04:49 PM
Windows XP Tricks & Tips!!!!..new ones. pranky Tutorials 9 08-23-2008 03:22 PM
Check if a file exists Lop C and C++ 4 08-07-2006 10:03 PM
Check if a File Exists NeedHelp C# Programming 4 08-07-2006 05:20 PM
Check if a URL Exists Chan PHP Forum 1 07-13-2006 12:54 PM


All times are GMT -5. The time now is 01:27 AM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
LogicKills ........ 20.00000
gaylo565 ........ 18.00000
WingedPanther ........ 15.00000
|pH| ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 67%

Ads