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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delphi and SSD disk

Status
Not open for further replies.

Audi30tdi

Programmer
Jun 3, 2019
1
0
0
NO
Hello!

Change to SSD on my computer, and now my Delphi7 Application is not working right.

Have the following code;

var
fil2 : text;

procedure ..........
begin
if fileexists('c:\auto\regnskap.dat')=true then begin
assignfile(fil2,'c:\auto\regnskap.dat');
reset(fil2);
....

The if fileexists line is working, and the program find the file, but the next line it give an error, "invalid file name"

This program/code have been working for years, but after I change to SSD it does not.

Any solutions??

Regards
Kåre!
 
Using your code (with the change from "text" to "TextFile", I wasn't able to recreate your error. I tried using Delphi 5 and Delphi 10.3 (both using an SSD). Are you sure the line that's failing is the AssignFile?
If you change the file name ('c:\auto\regnskap.dat') to something else or to a different path, does it still fail?

Mirtheil
 
Code:
procedure TForm1.Button1Click(Sender: TObject);
const
//  testfile = 'testfile.txt';
  testfile = 'c:\auto\testfile.txt';
var
  fil2 : TextFile;
  readtext: String;
begin
  if fileexists(testfile)=true then
    begin
      assignfile(fil2, testfile);
      reset(fil2);
      readln(fil2, readtext);
      MessageDlg('File Contents: ' + readtext, mtInformation, [mbOK], 0);
      CloseFile(fil2);
    end
  else
    MessageDlg('File not found.', mtWarning, [mbok], 0);
end;

Works perfectly on Delphi 3. What is the OS you're running this on? Only thing I can think of that would remotely cause what you state is the possibility that you don't have read/write privileges on the drive you're running this on.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top