Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EAccessViolation problem

Status
Not open for further replies.

Vovin

Programmer
Aug 24, 2003
63
GB
Hi,

I have an application that basically copies a file's contents into a new file and then adds some text at the end of the new copied file.

The trouble is I get the message "Project DigSig.exe raised exception class EAccessViolation with message 'Access Violation at address 00403B22 in module 'DigSig.exe'. Read of addess 450A4647'. Process stopped. Use Step or Run to continue.".

I stepped through the code and the exception is thrown when I try and close the copied file i.e.
CloseFile(g);

I just can't work out why this is happening as the same code runs fine in another project. Any help would be much appreciated. Here is a sample of the code:

try
new_filename := 'C:\temp\temp.pdf';
AssignFile(f, filename);
AssignFile(g, new_FileName);

try
Reset(f, 1); { Record size = 1 }
//Reset(g, 1); { Record size = 1 }
Rewrite(g, 1); { Record size = 1 }
//
// Create a copy of the file
//
repeat
BlockRead(f, Buf, SizeOf(Buf), NumRead);
BlockWrite(g, Buf, NumRead, NumWritten);
until (NumRead = 0) or (NumWritten <> NumRead);

//
// Add stuff to end of file
//

finally
CloseFile(f);
CloseFile(g); // causes exception to be raised
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top