Io Error 6 Delphi
16bit Delphi but it gives me I/O error 6 under Delphi 32bit. I'm reading and writing a file inplace and it looks like this error is invalid file handle, But I'm not sure. Does anyone know ? Torstein Petterse Delphi Developer Thu, 19 Nov 1998 03:00:00 GMT Re:I/O error 6 Quote> j...@atl.mindspring.com (john c. taylor) wrote in article <4osqb6$...@mule1.mindspring.com>... Quote> Can anyone tell me what an I/O error 6 is ? I've got a piece of code > that runs fine under 16bit Delphi but it gives me I/O error 6 under > Delphi 32bit. I'm reading and writing a file inplace and it looks > like this error is invalid file handle, But I'm not sure. > Does anyone know ? Error code 6 means invalid file handle. It may be that you have declared the read buffer before the File variable, and are trying to read more data than the buffer can hold. The buffer overflowes and your File variable is overwritten with the buffer overflow. I once had this problem myself and was unable to find what I/O error 6 meant. I had to find an old manual from Turbo Pascal for Windows to find a description of the error code. Hope this helps. Torstein Pettersen t...@online.no Torstein Petterse Delphi Developer Thu, 19 Nov 1998 03:00:00 GMT Re:I/O error 6 Quote> j...@atl.mindspring.com (john c. taylor) wrote in article <4osqb6$...@mule1.mindspring.com>... Quote> Can anyone tell me what an I/O error 6 is ? I've got a piece of code > that runs fine under 16bit Delphi but it gives me I/O error 6 under > Delphi 32bit. I'm reading and writing a file inplace and it looks > like this error is invalid file handle, But I'm not sure. > Does anyone know ? Error code 6 means invalid file handle. It may be that you have declared the read buffer before the File variable, and are trying to read more data than the buffer can hold. The buffer overflowes and your File variable is overwritten with the buffer overflow. I once had this problem myself and was unable to find what I/O error 6 meant. I had to find an old manual from Turbo Pascal for Windows to find a description of the error code. Hope this helps. Torstein Pettersen t...@online.no Svante Granqvis Delphi Developer Fri, 20 Nov 1998 03:00:00 GMT Re:I/O error 6 Quotejohn c. taylor wrote: > Can anyone tell me what an I/O error 6 is ? I've got a piece of code > that runs fine under 16bit Delphi but it gives me I/O error 6 under > Delphi 32bit. I'm reading and writing a file inplace and it looks > like this error is invalid file handle, But I'm not sure. > Does anyone know ? Maybe some part of you code writes in unallocated mem. Like: arr[17]:=17
I occasionally get I/O error 6 or 32. Heres my code: : [source code here, see previous message] In the copy below of the http://www.delphigroups.info/2/0b/141274.html first lines of your FormCreate procedure, I marked and commented the lines that can cause errors. Please let me know if this info solved your problem :) procedure TForm1.FormCreate(Sender: TObject); var SR: TSearchRec; Done: string; FName: http://www.festra.com/wwwboard/messages/13009.html string; InFile: textfile; LineofText: TextLines; i: integer; DotheEncryption: Boolean; begin DotheEncryption := False; Twofish1.InitialiseString('JanDunn'); If FindFirst('*.doc', faAnyFile, SR) = 0 then FName := SR.Name; { But... if FindFirst did NOT find a file, then FName doesn't contain a valid filename ! } AssignFile( InFile, Fname ); { If FName doesn't contain a valid filename, then InFile now points to a non-existing file } Reset(Infile); for i := 1 to 5 do begin { If InFile points to a non-existing file, then the next line will give an I/O error 6 } Readln(Infile, LineofText[i]); end; // etc... end; Related articles Follow Ups
Join INTELLIGENT WORK FORUMSFOR COMPUTER PROFESSIONALS Log In Come Join Us! Are you aComputer / IT professional?Join Tek-Tips Forums! Talk With Other Members Be http://www.tek-tips.com/viewthread.cfm?qid=1044806 Notified Of ResponsesTo Your Posts Keyword Search One-Click Access To YourFavorite http://www.cyberforum.ru/delphi-beginners/thread171220.html Forums Automated SignaturesOn Your Posts Best Of All, It's Free! Join Us! *Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting Guidelines Promoting, selling, recruiting, coursework and thesis posting is forbidden.Tek-Tips Posting Policies Jobs Jobs from Indeed What: io error Where: jobs by Link To This Forum! Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.Just copy and paste the BBCode HTML Markdown MediaWiki reStructuredText code below into your site. Embarcadero: Delphi Forum at Tek-Tips HomeForumsProgrammersDevelopment ToolsEmbarcadero: Delphi Forum File I/O error 6 while reading an empty File of Record thread102-1044806 Forum Search io error 6 FAQs Links MVPs File I/O error 6 while reading an empty File of Record File I/O error 6 while reading an empty File of Record glacialfury (Programmer) (OP) 17 Apr 05 15:56 For the record, I'm not very experienced in programming in general and with Delphi in particular; hence the poor practice of using goto's, so please be gentle .I have a program that, upon loading, checks to see whether a certain file exists.If it does not exist, an empty one is created; if it does exist, it should be loaded into the program.The creation of the empty file seems to work; however, when the program loads and tries to read that empty file, I get an I/O Error 106.If it is important, the file is a typed file for records; the records will contain three strings each.Here is the code for the offending procedure; I have marked off the area that is causing the area.I have tested it thoroughly to ensure that this is indeed the spot that is causing
Тесты Блоги Сообщество Поиск Ссылки сообщества Социальные группы Поиск Google по форуму Поиск Yandex по форуму Поиск по форуму Расширенный поиск Тесты Список тестов К странице... @STL1te 6 / 5 / 0 Регистрация: 08.12.2009 Сообщений: 105 01.10.2010, 13:27 I/O error 6 #1 при выполнении программа стопорится на строке Delphi1 while not eof(f) do при этом не давая даже ввести имя открываемого файла.. т.е строки Delphi1 2 writeln ('Ââåäèòå èìÿ ГґГ*éëГ*:'); read (f_name); она просто пропускает. вот код самой процедуры и ниже скрин ошибки. Процедура просто выводит на экран содержимое ранее созданного файла. Почему выскакивает ошибка не знаю..(( Delphi1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 procedure OpenFile (var f:CharFile); var f_name:string; ch:char; begin f_name:=''; writeln ('Ââåäèòå èìÿ ГґГ*éëГ*:'); read (f_name); assign (f,f_name); reset(f); while not eof(f) do begin read (f,ch); write (ch); end; closefile(f); end; Similar Эксперт 41792 / 34177 / 6122 Регистрация: 12.04.2006 Сообщений: 57,940 01.10.2010, 13:27 I/O error 6 Посмотрите здесь: I/O error 32 Delphi Delphi error buttonDelphi I/O errorошибка Socket Error #11001 или socket error #10051 Delphi Error Form Delphi После регистрации реклама в сообщениях будет скрыта и будут доступны все возможности форума. @anonimus 2148 / 1237 / 31 Регистрация: 28.04.2010 Сообщений: 4,531 01.10.2010, 13:29 I/O error 6 #2 может потому что ты его (файл) не закрыл после assign и вообще лучше AssignFile использовать @STL1te 6 / 5 / 0 Регистрация: 08.12.2009 Сообщений: 105 01.10.2010, 13:46 [ТС] I/O error 6 #3 вот весь код.. вроде файл закрываю ещё в процедуре CreateFile.. Delphi1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 program Project2; {$APPTYPE CONSOLE} uses SysUtils, Windows; type CharFile=file of char; procedure CreateFile (var f:CharFile); var f_name:string; ch:char; begin f_name:=''; write ('Ââåäèòå èìÿ ГґГ*éëГ*:'); readln (f_name); assignfile (f,f_name); rewrite (f); writeln ('Ââåäèòå ýëåìåГ*ГІГ» ГґГ*éëГ* (ГЄГ®Г*ГҐГ¶ ГґГ*éëГ* - .)'); repeat read (ch); write (f,ch); until ch='.'; closefile (f); end; procedure OpenFile (var f:CharFile); va