代码之家  ›  专栏  ›  技术社区  ›  mat_geek

为什么我尝试使用open for writing打开文件失败?艾达95

  •  1
  • mat_geek  · 技术社区  · 16 年前

    当我试图打开要写入的文件时,出现ada.io_exceptions.name_错误。

    过程调用是 打开

    文件名为“c:\ cc_test_log.txt”。此文件不存在。

    这是在windows xp的ntfs分区上。用户具有创建和写入目录的权限。 文件名远低于win32最大路径长度。

     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;
    
    1 回复  |  直到 16 年前
        1
  •  2
  •   Community Mohan Dere    9 年前

    如果“文件不存在”,您应该 Create 首先。

    如果这与你的 previous question ,可能有助于提供更多详细信息。