Solved

Check if file Exist only

Posted on 2001-08-20
7
206 Views
Last Modified: 2010-04-06
Hello when i start my application the first thing i want it to do automatically is check to see if a file exist in a dir.

the file is called   Check.dat its in C:\

now if Check.dat exist then do nothing

but if Check.dat is not exist then the Appliacation Exits

thanks in advance  give to me full example because i am new and learning thank you
0
Comment
Question by:neopolis
  • 3
  • 2
  • 2
7 Comments
 
LVL 2

Expert Comment

by:PeterLarsen
Comment Utility
Im not sure this is what you want, but this should do it :

if FileExists('c:\Check.dat') then do something...

Regards
Peter
0
 

Author Comment

by:neopolis
Comment Utility
Hi Peter

what i want is some code

that checks for the Check.dat file in windows dir
if the file is there then the application stay running

if the file is not there then the application Exits

thanks
0
 
LVL 3

Accepted Solution

by:
VSF earned 10 total points
Comment Utility
Open your .dpr by going on Menu>Project>ViewSource

Add SysUtils to uses clause
and before the "Application.run;" add the if statement!
The final code of your .dpr should look like this:

program Project1;

uses
  Forms,Sysutils,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  if fileexists('ADD HERE THE PATH OF THE FILE') then
   Application.Run
  else                 //Terminates the program if notfound
   application.terminate;
end.



Hope this helps!
VSF
www.victory.hpg.com.br

0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 2

Expert Comment

by:PeterLarsen
Comment Utility
Yo VSF,

I think what Neopolis want is to search throught the windows directory.
To do that you must open the registry first to find the path :-(

/Peter :-)
0
 

Author Comment

by:neopolis
Comment Utility
Thank you Peter
0
 
LVL 3

Expert Comment

by:VSF
Comment Utility
PeterLarsen:
Noops... I think that was what he needed!

Neopolis:
I'm glad to help!

Post your questions if you have any problems... We'll allways be here to try to solve then!

VSF
UIN:14016999

Please show your support by entering my sites!
www.victory.hpg.com.br
www.enge.cjb.net
0
 

Author Comment

by:neopolis
Comment Utility
i went to your site cool i bookmarked so i will be back
*smiles*
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now