I/O error 32 when manipulating files

Posted on 2002-08-28
Medium Priority
Last Modified: 2010-04-04
hi, when I did the coding to manipulate the file, i also met I/O error, the problem occurs when hitting the following command:
I am using windows 2000 and Delphi 6.0. Please tell me what happens and how to solve this problem!!!
Question by:cdbdelphi

Expert Comment

ID: 7248259
Please post your code that generate the error, then we can help.
I/O errors has alot of meansings
LVL 17

Expert Comment

ID: 7248268
rewrite creates and opens a file ,
i/o 32 error is a "sharing violation"
(ie the file is already opened.)

so it sounds like you already opened the file, maybe using filecreate(),if that is the case then use fileclose() before calling rewrite()

example from help on rewrite usage:

var F: TextFile;

  AssignFile(F, 'NEWFILE.$$$');
  Writeln(F, 'Just created file with this text in it...');

if you still have problems post you code here

Expert Comment

ID: 7248305
The win32 errorcode nr 32:

The process cannot access the file because it is being used by another process.

Accepted Solution

maio earned 150 total points
ID: 7262157

The error is a sharing violation, which can mean that your or another program has this files opened. For a <rewrite> you'll need of course exclusive rights, so the error has to occur, if there's something wrong.
Of course, if your program had opened the file before, you will have to close it, but maybe there's another program - in that case you only can prevent that ugly error-message by checking if your <rewrite> is possible.
Therefore you can disable the error-check temporarily :

 {$I-} // I/O-checking OFF
 {$I+} // I/O-checking ON - you should let it on elsewhere
 if Ioresult<>0 then begin
   // the file couldnt be created
 end else begin
   // all ok, file is rewritten

 Writeln(F, 'Just created file with this text in it...');

Author Comment

ID: 7263468
Thanks a lot for you guys help! I try to solve that problem and I learn a lot more than the problem itself. It is a great place to get what I want to know...

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

850 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