?
Solved

I/O error 32 when manipulating files

Posted on 2002-08-28
5
Medium Priority
?
5,270 Views
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:
  Rewrite(tempfile);
I am using windows 2000 and Delphi 6.0. Please tell me what happens and how to solve this problem!!!
Thanks
0
Comment
Question by:cdbdelphi
5 Comments
 
LVL 7

Expert Comment

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

Expert Comment

by:inthe
ID: 7248268
hi,
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;

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


if you still have problems post you code here
0
 

Expert Comment

by:Buda
ID: 7248305
The win32 errorcode nr 32:

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

Accepted Solution

by:
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
 Rewrite(F);
 {$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
 end


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

Author Comment

by:cdbdelphi
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...
rgds
0

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