|
아래의 리스트는 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진으로 읽어오려면 어떻게 해야 하나요???
:
: 아시는 분 답변 바랍니다...
:
: 좋은 하루 되세요~
:
|