간단한 텍스트 모드 파일 쓰기 예제
CFile file;
file.Open("outfile.txt", CFile::modeCreate | CFile::modeWrite | CFile::typeText , NULL);
file.Write("1234567890", 10);
file.Close();
----------------------------------------------------------------------
버퍼로 바이너리 파일 불러오기 예제
CFile file;
int len;
char* buf;
len = file.GetLength();
buf = (char*)malloc(sizeof(char)*len);
file.ReadHuge(buf,len);
file.Close();
free(buf);
----------------------------------------------------------------------
파일의 속성은 아래에서 원하는 것을 쓸 수 있다.
CFile::modeCreate Directs the constructor to create a new file. If the file exists already, it is truncated to 0 length.
CFile::modeNoTruncate Combine this value with modeCreate. If the file being created already exists, it is not truncated to 0 length. Thus the file is guaranteed to open, either as a newly created file or as an existing file. This might be useful, for example, when opening a settings file that may or may not exist already. This option applies to CStdioFile as well.
CFile::modeRead Opens the file for reading only.
CFile::modeReadWrite Opens the file for reading and writing.
CFile::modeWrite Opens the file for writing only.
CFile::modeNoInherit Prevents the file from being inherited by child processes.
CFile::shareDenyNone Opens the file without denying other processes read or write access to the file. Create fails if the file has been opened in compatibility mode by any other process.
CFile::shareDenyRead Opens the file and denies other processes read access to the file. Create fails if the file has been opened in compatibility mode or for read access by any other process.
CFile::shareDenyWrite Opens the file and denies other processes write access to the file. Create fails if the file has been opened in compatibility mode or for write access by any other process.
CFile::shareExclusive Opens the file with exclusive mode, denying other processes both read and write access to the file. Construction fails if the file has been opened in any other mode for read or write access, even by the current process.
CFile::shareCompat This flag is not available in 32 bit MFC. This flag maps to CFile::shareExclusive when used in CFile::Open.
CFile::typeText Sets text mode with special processing for carriage return?linefeed pairs (used in derived classes only).
CFile::typeBinary Sets binary mode (used in derived classes only).
CFile file;
file.Open("outfile.txt", CFile::modeCreate | CFile::modeWrite | CFile::typeText , NULL);
file.Write("1234567890", 10);
file.Close();
----------------------------------------------------------------------
버퍼로 바이너리 파일 불러오기 예제
CFile file;
int len;
char* buf;
len = file.GetLength();
buf = (char*)malloc(sizeof(char)*len);
file.ReadHuge(buf,len);
file.Close();
free(buf);
----------------------------------------------------------------------
파일의 속성은 아래에서 원하는 것을 쓸 수 있다.
CFile::modeCreate Directs the constructor to create a new file. If the file exists already, it is truncated to 0 length.
CFile::modeNoTruncate Combine this value with modeCreate. If the file being created already exists, it is not truncated to 0 length. Thus the file is guaranteed to open, either as a newly created file or as an existing file. This might be useful, for example, when opening a settings file that may or may not exist already. This option applies to CStdioFile as well.
CFile::modeRead Opens the file for reading only.
CFile::modeReadWrite Opens the file for reading and writing.
CFile::modeWrite Opens the file for writing only.
CFile::modeNoInherit Prevents the file from being inherited by child processes.
CFile::shareDenyNone Opens the file without denying other processes read or write access to the file. Create fails if the file has been opened in compatibility mode by any other process.
CFile::shareDenyRead Opens the file and denies other processes read access to the file. Create fails if the file has been opened in compatibility mode or for read access by any other process.
CFile::shareDenyWrite Opens the file and denies other processes write access to the file. Create fails if the file has been opened in compatibility mode or for write access by any other process.
CFile::shareExclusive Opens the file with exclusive mode, denying other processes both read and write access to the file. Construction fails if the file has been opened in any other mode for read or write access, even by the current process.
CFile::shareCompat This flag is not available in 32 bit MFC. This flag maps to CFile::shareExclusive when used in CFile::Open.
CFile::typeText Sets text mode with special processing for carriage return?linefeed pairs (used in derived classes only).
CFile::typeBinary Sets binary mode (used in derived classes only).
'프로그래밍' 카테고리의 다른 글
[Study]Embedded zerotree wavelet (EZW) algorithm (0) | 2003.07.12 |
---|---|
[Study]RGB와 YCrCb 간의 Conversion (0) | 2003.07.12 |
[C/C++]http://www.cplusplus.com/ (0) | 2003.07.12 |
[MFC]팝업메뉴(Context Menu) 만들기 (0) | 2003.07.12 |
[객체지향설계] UML의 개요 (0) | 2003.07.12 |