1
当我尝试打开要写入的文件时,我得到一个Ada.IO_Exceptions.Name_Error。在Ada中,为什么我尝试打开一个写入失败的文件?
文件名是“C:\ CC_TEST_LOG.TXT”。该文件不存在。
这是在NTFS分区上的Windows XP上。用户有权创建并写入目录。 文件名远远低于WIN32最大路径长度。
name_2 : String := "C:\CC_TEST_LOG.TXT"
if name_2'last > name_2'first then
begin
Ada.Text_IO.Create(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;
我可以使用虚拟化XP中发布的代码创建并打开(或覆盖)该文本文件。我唯一能想到的是,在你的情况下,文件已经存在,运行该代码的用户没有正确的权限来访问或修改它。哪一个是你的情况中抛出的异常? – Xandy 2010-03-10 02:22:04