Solved

Check if file Exist only

Posted on 2001-08-20
7
209 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
ID: 6408795
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
ID: 6409455
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
ID: 6409469
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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 2

Expert Comment

by:PeterLarsen
ID: 6409504
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
ID: 6409852
Thank you Peter
0
 
LVL 3

Expert Comment

by:VSF
ID: 6410758
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
ID: 6412547
i went to your site cool i bookmarked so i will be back
*smiles*
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi Form ownership 4 90
Delphi...Split view - idea? 1 68
I want to use librsync in my Delphi backup application. 3 50
Multi-layered image in FireMonkey 9 34
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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