C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[17911] Re:FileOpen 함수로 파일 읽어올때 바이너리로 읽는 방법?
민인학 [h2h1995] 2560 읽음    2002-04-24 21:26
아래의 리스트는 FileOpen할때 두번째 아규먼트에 넣어주는 모드들인데요...

fmOpenRead    Open for read access only.
fmOpenWrite    Open for write access only.
fmOpenReadWrite    Open for read and write access.
fmShareCompat    Compatible with the way FCBs are opened.
fmShareExclusive    Read and write access is denied.
fmShareDenyWrite    Write access is denied.
fmShareDenyRead    Read access is denied.
fmShareDenyNone    Allows full access for others.

FileOpen을할때..
텍스트로 읽을지.. 이진으로 읽을지의 모드는 없습니다.
그건 프로그래머가 판단을 해서 FileRead에서 처리를 해줘야할 문제입니다.
차라리 안시표준함수인 open을 사용하시죠...

아래는 FileOpen과 FileRead의 예제입니다.


void __fastcall TForm1::Button1Click(TObject *Sender)

{
  int iFileHandle;
  int iFileLength;
  int iBytesRead;
  char *pszBuffer;
  if (OpenDialog1->Execute())
  {
    try
    {
      iFileHandle = FileOpen(OpenDialog1->FileName, fmOpenRead);
      iFileLength = FileSeek(iFileHandle,0,2);
      FileSeek(iFileHandle,0,0);
      pszBuffer = new char[iFileLength+1];
      iBytesRead = FileRead(iFileHandle, pszBuffer, iFileLength);
      FileClose(iFileHandle);

      for (int i=0;i<iBytesRead;i++)
      {
        StringGrid1->RowCount += 1;
        StringGrid1->Cells[1][i+1] = pszBuffer[i];
        StringGrid1->Cells[2][i+1] = IntToStr((int)pszBuffer[i]);
      }
      delete [] pszBuffer;
    }
    catch(...)
    {
      Application->MessageBox("Can't perform one of the following file operations: Open, Seek, Read, Close.", "File Error", IDOK);
    }
  }
}

임양규 님이 쓰신 글 :
: 안녕하세요???
:
: 예전에 C에서는 open 함수에는 파일을 텍스트로 읽을지, 바이너리로 읽을지 지정해주는 옵션이 있었는데...빌더의 FileOpen함수에는 그런 옵션이 없는것 같네요...
:
: FileOpen을 사용해서 화일을 2진으로 읽어오려면 어떻게 해야 하나요???
:
: 아시는 분 답변 바랍니다...
:
: 좋은 하루 되세요~
:

+ -

관련 글 리스트
17908 FileOpen 함수로 파일 읽어올때 바이너리로 읽는 방법? 임양규 1072 2002/04/24
17911     Re:FileOpen 함수로 파일 읽어올때 바이너리로 읽는 방법? 민인학 2560 2002/04/24
17929         Re:Re:FileOpen 함수로 파일 읽어올때 바이너리로 읽는 방법? 임양규 1006 2002/04/25
17934             Re:Re:Re:FileOpen 함수로 파일 읽어올때 바이너리로 읽는 방법? 민인학 1409 2002/04/25
17944                 Re:Re:Re:Re:FileOpen 함수로 파일 읽어올때 바이너리로 읽는 방법? 임양규 1072 2002/04/25
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.