Q&A

  • 텍스트 파일 읽어오기 어떻게 하나요?
    if fileExists(f_path+'test.txt') then begin
showmessage('텍스트 파일 할당');
      AssignFile(data_file, f_path+'test.txt');
showmessage('세팅');
      Reset(data_file);

      while not eof(data_file) do begin
        Readln(data_file, buf);
        showmessage(buf);
      end;
      closeFile(data_file);
    end
    else showmessage('파일없음');

f_path+'test.txt' => 이 파일이 있는데 '파일없음' 메세지가 뜨거든요.
텍스트파일 내용을 읽어오려는데 잘 안되네요.
파일 있는지 체크하는 부분을 주석으로 막고 하면..
  Reset(data_file);  여기서 ' file not found ' 에러나구요..  
왜이런지 모르겠습니다.
방법좀 알려주세요~


1  COMMENTS
  • Profile
    김수경 2003.04.27 00:27
    프로그램 내용엔 이상이 없어 보입니다.

    f_path + 'test.txt'를 화면에 출력해 보시고

    그 Path의 File이 있는지 수작업으로 직접 확인해 보시기 바랍니다.


    참고로 Text File을 읽는 것이라면

    TStringList.LoadFrom() Method를 사용해 보십시오.

       예> TMemo1.Lines.LoadFromFile( 'C:Autoexec.bat' );

    즐푸하세요 ^^;