Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

File manipulation

Posted on 1997-04-02
1
Medium Priority
?
168 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 100 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

886 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