Why are my attempts to open a file using open for writing failing? Ada 95
Question
When I attempt to open a file to write to I get an Ada.IO_Exceptions.Name_Error.
The procedure call is Ada.Text_IO.Open
The file name is "C:\CC_TEST_LOG.TXT". This file does not exist.
This is on Windows XP on an NTFS partition. The user has permissions to create and write to the directory. The filename is well under the WIN32 max path length.
name_2 : String := "C:\CC_TEST_LOG.TXT"
if name_2'last > name_2'first then
begin
Ada.Text_IO.Open(file, Ada.Text_IO.Out_File, name_2);
Ada.Text_IO.Put_Line(
"CC_Test_Utils: LogFile: ERROR: Open, File "
& name_2);
return;
exception
when The_Error : others =>
Ada.Text_IO.Put_Line(
"CC_Test_Utils: LogFile: ERROR: Open Failed; "
& Ada.Exceptions.Exception_Name(The_Error)
& ", File " & name_2);
end;
end if;
Solution
If the "file does not exist," you should Create
it first.
If this is related to your previous question, it may help to provide more details.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow