I O Error 103 No Delphi
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business what is i/o error 103 Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
I O Error 103 Windows 7
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like i/o error 103 realterm you, helping each other. Join them; it only takes a minute: Sign up Delphi: Why do I sometimes get an I/O Error 103 with this code? up vote 10 down vote favorite 4 In several of my
What Does I/o Error 103 Mean
apps I have code similar to the following: if ForceDirectories(ExtractFilePath(lLogName)) then begin AssignFile(lLog, lLogName); try if FileExists(lLogName) then Append(lLog) else Rewrite(lLog); Writeln(lLog, lLogLine); finally {$I-}CloseFile(lLog);{$I+} end; end; In one application, the first time I try to execute this I consistently get an I/O Error 103 exception on the line with the Append statement (the file does exist prior to calling this). All subsequent attempts at the operation will work fine however - until I restart the i/o error 103 windows app. All the docs I found about this error so far indicated that this would either be caused by calling CloseFile without prior Reset or Rewrite (Append typically isn't mentioned) or if the file was in use by another process. As the exception occurs before the call to CloseFile it obviously couldn't be the former. I already tried inserting a Reset right after the AssignFile for good measure but then I get the exception on that line. There is also no other application overtly accessing that file. I say "overtly" because I do have a slight suspicion that anti-virus (TrendMicro in my case) might be the cuplrit here (so maybe the file is in use). If that was indeed the problem, what would be the best way around it? Hard-coding an automatic retry does not really feel like a clean solution to me... Another case where I sometimes get the 103 error is this code, which I use to create an empty file (or more often to empty an existing file): AssignFile(lFile, AFileName); try Rewrite(lFile); finally CloseFile(lFile); end; In this case it's much harder to reproduce. It happens a lot less often. Most of the time this seems to happen on the first run after I recompiled the application. Could this again be the anti-virus getting in the way? I have only ever s
Search Advanced Search Go to Page... Thread Tools Display Modes #1 06-13-2002, 02:11 PM MrBaseball34 Senior Member Join Date: Jan
I/0 Error 103
2001 Posts: 7,260 Prevent I/O Error 103 Not used to Std. I/O
I/o Error 103 Screensaver
operations... When using AssignFile and CloseFile, I am sometimes getting a 103 error (File is not open). How delphi rewrite can I check to see if, in fact, the file is open before the CloseFile call? MrBaseball34 View Public Profile Visit MrBaseball34's homepage! Find all posts by MrBaseball34 #2 http://stackoverflow.com/questions/634587/delphi-why-do-i-sometimes-get-an-i-o-error-103-with-this-code 06-13-2002, 02:37 PM vandub Member Join Date: Aug 2001 Posts: 44 RE: Prevent I/O Error 103 you could use the {$i-} command then check the ioresult for an error AssignFile(F, FileName); {$I-} Reset(F); {$I+} if IOResult = 0 then MessageDlg('File size in bytes: ' + IntToStr(FileSize(F)), mtInformation, [mbOk], 0) else MessageDlg('File access error', mtWarning, [mbOk], 0); vandub View Public http://www.delphipages.com/forum/showthread.php?t=58954 Profile Send a private message to vandub Visit vandub's homepage! Find all posts by vandub #3 06-13-2002, 02:37 PM HTML Senior Member Join Date: Jan 2001 Posts: 2,977 RE: Prevent I/O Error 103 Hello, This site has many examples on File I/O and uses IoResult(should return 0 if successfull) in few places in the snippets. http://homepages.borland.com/efg2lab/Library/Delphi/IO/FileIO.htm If perhaps you can post a snippet of your code that you think cuases the problem , that would help. :-) HTML View Public Profile Send a private message to HTML Visit HTML's homepage! Find all posts by HTML #4 06-13-2002, 10:35 PM PoseFant Senior Member Join Date: Jan 2001 Posts: 1,002 RE: Prevent I/O Error 103 you could use the {$i-} command then check the ioresult for an error AssignFile(F, FileName); {$I-} Reset(F); {$I+} if IOResult = 0 then MessageDlg('File size in bytes: ' + IntToStr(FileSize(F)), mtInformation, [mbOk], 0) else MessageDlg('File access error', mtWarning, [mbOk], 0); --- Regards /Filip I've lost my autosignature ... *sobbing* ... PoseFant View Public Profile Send a private message to PoseFant Visi
to return a user-selected file name. I then use AssignFile() to get a file handle. Finally, I try to open the file with a Reset(). When the http://www.delphigroups.info/2/a0/520309.html Reset function executes, it gives me and io error 103. The Help for Reset doesn't even suggest that 103 is a result of an error with Reset. This is probably a common mistake. I'm new to Delphi, http://embarcadero.newsgroups.archived.at/public.delphi.nativeapi/201003/1003033518.html and would like to move up from VB usage. However, errors like this that make no sense discourage me. If I set a breakpoint at the AssignFile(), I can see that the filname is correct. it's error 103 only at the Reset() that it fails. I went through the bother to reset permissions on the parent directory of the file to be opened, but that was not the problem. I'm sure I'm making a common mistake. What might it be? Thanks for the help. Dale Seaburg Dave Nottag Delphi Developer Thu, 20 Nov 2003 09:48:14 GMT Re:IO Error 103 with Reset() Quote"Dale Seaburg" wrote: > I am using an OpenDialog to o error 103 return a user-selected file name. I then > use AssignFile() to get a file handle. Finally, I try to open the file > with a Reset(). When the Reset function executes, it gives me and io > error 103. The Help for Reset doesn't even suggest that 103 is a result > of an error with Reset. Please post the code, and *exactly* where the error occurs. Its possible that the error is the result of some other action. -- Dave Nottage Barry Kell Delphi Developer Thu, 20 Nov 2003 10:09:59 GMT Re:IO Error 103 with Reset() Quote"Dale Seaburg"
file ERROR 103 Subject: Windows 7 - Write to file ERROR 103 Posted by: Sumerset sumerset Date: Wed, 3 Mar 2010 Hello, I'm trying to write a component that logs the activity of an application. The code works fine in Windows XP and Windows Vista however when i run it in a Windows 7 pc i get a "I/O error 103". Does anyone have this problem and know how to solve it? I'm using Delphi2010 and the following code: Procedure Component.create begin SetCurrentDir(GetCurrentDir); if (not(DirectoryExists('Log'))) then begin CreateDir('Log'); end; SetCurrentDir(GetCurrentDir+'\LOG'); try AssignFile(pLog_file,Time.UTCtimestamp(time.localtoutc(Time.getnowtime))+'.txt'); except closefile(plog_file); end; end; Procedure Component.start; begin try rewrite(plog_file); writeln(plog_file ,utf8string('Log started')); pstate:=stateon; except closefile(plog_file); end; end;Replies Re: Windows 7 - Write to file ERROR 103 [Edit] posted by karl pritchett on Wed, 3 Mar 2010 Newsgroups.Archived.At is © Copyright 2009-2016, A B Cryer, All Rights Reserved.