Reputation: 33
I am testing a login and account creation program. When the user presses the Create New Account button it prompts them to enter a Username (which saves to a variable-sNewUsername) and a Password (which saves to a variable-sNewPassword). The password is saved to a text file. For some reason, it gives me the 'I/O Error 105' when trying to save the password to the text file.
I have run the debug tool and it saves to the variable fine but does not Write to the text file. I have double checked if I have used Rewrite instead of Reset and all looks fine.
AssignFile(tf,sNewUsername + '.txt');
Rewrite(tf);
writeln(sNewPassword);
closefile(tf);
I expected the file to save the Password from the variable to the text file but it does not write the password to the text file and give an error i do not understand ('I/O error 105').
Upvotes: 3
Views: 10086
Reputation: 612954
Your call to writeln
is not providing a file object, and so attempts to write to the standard output, which presumably does not exist in your process.
Change it to
writeln(tf, sNewPassword);
However, you should probably use a more modern mechanism to write a file. Further, you are running a serious risk that you won't write the file to the desired directory because you only specify a relative path.
Upvotes: 5