Delphi 7 I/o Error 32
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the
I/o Error 32 Windows 7
workings and policies of this site About Us Learn more about Stack i/o error 32 game maker Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs
Einouterror
Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join delphi i/o error 103 them; it only takes a minute: Sign up Delphi multi-threading file write: I/O error 32 up vote 0 down vote favorite I created a class for writing thread-safe log in a text file using CriticalSection. I am not an expert of CriticalSection and multi-threading programming (...and Delphi), I'm definitely doing something wrong... unit ErrorLog; interface uses Winapi.Windows, System.SysUtils; type TErrorLog exception einouterror in module file access denied = class private FTextFile : TextFile; FLock : TRTLCriticalSection; public constructor Create(const aLogFilename:string); destructor Destroy; override; procedure Write(const ErrorText: string); end; implementation constructor TErrorLog.Create(const aLogFilename:string); begin inherited Create; InitializeCriticalSection(FLock); AssignFile(FTextFile, aLogFilename); if FileExists(aLogFilename) then Append(FTextFile) else Rewrite(FTextFile); end; destructor TErrorLog.Destroy; const fmTextOpenWrite = 55218; begin EnterCriticalSection(FLock); try if TTextRec(FTextFile).Mode <> fmTextOpenWrite then CloseFile(FTextFile); inherited Destroy; finally LeaveCriticalSection(FLock); DeleteCriticalSection(FLock); end; end; procedure TErrorLog.Write(const ErrorText: string); begin EnterCriticalSection(FLock); try WriteLn(FTextFile, ErrorText); finally LeaveCriticalSection(FLock); end; end; end. to test the class I created a form with a timer set to 100 milliseconds: procedure TForm1.Timer1Timer(Sender: TObject); var I : integer; aErrorLog : TErrorLog; begin aErrorLog := nil; for I := 0 to 1000 do begin try aErrorLog := TErrorLog.Create(FormatDateTime('ddmmyyyy', Now) + '.txt'); aErrorLog.Write('new line'); finally if Assigned(aErrorLog) then FreeAndNil(aErrorLog); end; end; end; the logs are written, but occasionally raise I/O Error 32 exception on CloseFile(FTextFile) (probably because in use in another thread) where am I doing wrong? UPDATE: after reading all the comments and the answers I have totally changed approach. I share my solution. ThreadUtilities.pas (* Implemented for Delphi3000.co
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Expand
Delphi Assignfile
Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > I/O error 32 when manipulating files Want to Advertise Here? Solved I/O error 32 when manipulating files Posted on 2002-08-28 Delphi 1 Verified Solution 5 Comments 3,113 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 http://stackoverflow.com/questions/27202975/delphi-multi-threading-file-write-i-o-error-32 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 Question by:cdbdelphi Facebook Twitter LinkedIn Google Best Solution bymaio The error is a sharing violation, which can mean that your or another program has this files opened. For a
Advanced Search Go to Page... Thread Tools Display Modes #1 03-06-2002, 02:34 AM Dracula Junior Member Join Date: Mar 2002 Posts: 7 I/O error http://www.delphipages.com/forum/showthread.php?t=47739 32 ??? Hi, I'm building a tool in Delphi to view history log files of another program. There's no problem when I open such files using an untyped file variable. But since I want http://www.clubdelphi.com/foros/showthread.php?t=64346 to parse the history one line at a time, I really want to open them as 'textfile'. But when I do so, an I/O error 32 occurs on the statement "Reset(F)" I've searched i/o error the help pages and on the internet, but can't find anything about what this error means. At the moment, I'm using this trick to copy the entire file using the untyped file variable, and then open the copy as textfile. But since the files can become really big and I simply want to know what's happening, I'd like to fix the problem more elegantly Other effects i/o error 32 on the history files: DeleteFile(..) results in False when the history file is opened by the other program (sounds logical), however I can open the file and truncate it at the first byte But then, next time I try to open it, my viewer crashes (application error)... I know it's not very nice to truncate an open file, probably the other program doesn't even know it happened, and thus writes at the wrong locations... In conclusion: this is my question: what does "I/O error 32" mean? Kind regards, Sebastian Groeneveld Dracula View Public Profile Send a private message to Dracula Visit Dracula's homepage! Find all posts by Dracula #2 03-06-2002, 04:39 AM andyho Senior Member Join Date: Jul 2001 Posts: 1,446 RE: I/O error 32 ??? IO error 32 means "sharing violation" - the file you're trying to open is already open, either you forgot the closefile earlier, or a second application is using it. Bye, Andy andyho View Public Profile Visit andyho's homepage! Find all posts by andyho #3 03-06-2002, 04:48 AM GoodFun Senior Member Join Date: Jan 2001 Posts: 2,645 RE: I/O error 32 ??? Hi there, I strongly sug
en Tema Desplegado #1 27-03-2009 velezbunzl Miembro Registrado: Feb 2009 Posts: 16 Error I/O 32 buenas atrdes, mi problema es este mi programa escribe un archivo de texto que luego utilizo para crear una matriz y poder ahcer unas operacioens con la matriz, lo que sucede es que luego de cerrar el programa y abrirlo pro segudna vez cada qeu trato de ingresar un buevo dato me aparece este error, trate de cerrar e larchivo cuando creo la matriz pero ya el problema es que no puedo realizar las oepraciones, y si pongo el procedfimiento para crear la amtriz en el form active cada vez que le doy calcular las operaciones me aumetna el numero de datos al doble de lso que tengo velezbunzl Ver Perfil Encontrar Todos los Mensajes de velezbunzl #2 27-03-2009 [duilioisola] Miembro Premium Registrado: Aug 2007 Ubicación: Barcelona, España Posts: 1.362 Seguramente te haz dejado abierto el archivo ó lo tienes abierto con otra aplicación ó lo abres dos veces ó lo cierras antes de abrirlo ó nunca lo abres ó estas tratando de escribir en un archivo solo lectura ó ... Escribe alguna línea de cómo lo abres y cierras el archivo para que podamos ver dónde está el error. También puedes tomarte unos minutos para corregir faltas de ortografía, poner mayúsculas y minúsculas dónde corresponda, poner un punto cada tanto para separar frases, etc. Hay un miembro en el club que pone en su firma: Cita: El tiempo invertido en la respuesta es directamente proporcional al tiempo invertido en la pregunta. Espero no te ofendan mis comentarios... duilioisola Ver Perfil Encontrar Todos los Mensajes de duilioisola #3 27-03-2009 velezbunzl Miembro Registrado: Feb 2009 Posts: 16 aqui esta la undiad tipos Código: unit Tipos; interface uses Controls; type TPeriodoMedicion = (Manhana, Tarde, Noche); TTipoMedicion = (Diastolica, Sistolica); TMedicionPresion = record ValorMedicion: Integer; PeriodoMedicion : TPeriodoMedicion; TipoMedicion : TTipoMedicion; Fecha : TDate; end; implementation end. aqui esta la unidad de los datos que es doden lso ingreso Código: unit U_Datos; interface uses Windows, Messages, SysUtils, Varian