Solved

File manipulation

Posted on 1997-04-02
1
144 Views
Last Modified: 2010-04-03
Is there a procedure I should use to do the following things in Delphi?

I have two files A and B, and I want to:

- Delete file A on disk
- Rename file B as A

I have tried the following code but it doesn't work, it's like if the processor pass throught renaming step because deleting file A is not finished yet (the disk is too slow for the processor in multitasking win95)....

DeleteFile('c:\developp\Delphi\Patrick\CourrierElec\setbox.ini');

RenameFile('c:\developp\Delphi\Patrick\CourrierElec\setboxtemp.ini','c:\developp\Delphi\Patrick\CourrierElec\setbox.ini')

So, if you can help, I will appreciate it :)

Patrick St-Amant
0
Comment
Question by:pasta
1 Comment
 
LVL 2

Accepted Solution

by:
javiertb earned 50 total points
ID: 1335099
You can try this:

var value: boolean;

    chdir('c:\directory');  //Move where your files are stored
    DeleteFile('file1');

    value:=False;

    while (not value) do
    begin
          chdir('c:\directory');
          value:=RenameFile('file2','file1');
    end;

Hope this helps.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 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

21 Experts available now in Live!

Get 1:1 Help Now