ì°¸ê³ ¶
| MFC 파� 스트림 | http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cstring.asp |
| 파�복사 프로그램 | http://blog.naver.com/kds6221.do?Redirect=Log&logNo=140013999545 |
| 파ì�¼ìž…ì¶œë ¥ ì˜ˆì œ | http://blog.naver.com/popo1008.do?Redirect=Log&logNo=20008968622 |
| memDC -> bitmap | http://blog.naver.com/zenix4078.do?Redirect=Log&logNo=11507823 |
대략ì �ì�¸ CFile ¶
Data Members
Construction
Input/Output
Position
Locking
Status
Static
| m_hFile | Usually contains the operating-system file handle. |
| CFile | Constructs a CFile object from a path or file handle. |
| Abort | Closes a file ignoring all warnings and errors. |
| Duplicate | Constructs a duplicate object based on this file. |
| Open | Safely opens a file with an error-testing option. |
| Close | Closes a file and deletes the object. |
| Read | Reads (unbuffered) data from a file at the current file position. |
| ReadHuge | Can read more than 64K of (unbuffered) data from a file at the current file position. Obsolete in 32-bit programming. See Read. |
| Write | Writes (unbuffered) data in a file to the current file position. |
| WriteHuge | Can write more than 64K of (unbuffered) data in a file to the current file position. Obsolete in 32-bit programming. See Write. |
| Flush | Flushes any data yet to be written. |
| Seek | Positions the current file pointer. |
| SeekToBegin | Positions the current file pointer at the beginning of the file. |
| SeekToEnd | Positions the current file pointer at the end of the file. |
| GetLength | Retrieves the length of the file. |
| SetLength | Changes the length of the file. |
| LockRange | Locks a range of bytes in a file. |
| UnlockRange | Unlocks a range of bytes in a file. |
| GetPosition | Retrieves the current file pointer. |
| GetStatus | Retrieves the status of this open file. |
| GetFileName | Retrieves the filename of the selected file. |
| GetFileTitle | Retrieves the title of the selected file. |
| GetFilePath | Retrieves the full file path of the selected file. |
| SetFilePath | Sets the full file path of the selected file. |
| Rename | Renames the specified file (static function). |
| Remove | Deletes the specified file (static function). |
| GetStatus | Retrieves the status of the specified file (static, virtual function). |
| SetStatus | Sets the status of the specified file (static, virtual function). |
CFile Prototype ¶
ì „í™”ë°›ì•„ë�¼ ì�´ìŠ¹í•œ-_-
파ì�¼ ìž…ì¶œë ¥ 부분ì—� ì�˜í•´ "TestFile.txt"ë�¼ëŠ” 파ì�¼ì�„ ë§Œë“¤ê³ ,
CFile �래스 내� Write() 함수를 �용해서 'A' ~ 'Z' 까지 � 넣는 함수 (OnWriteFile())와,
파ì�¼ì—� 쓰여진 'A' ~ 'Z'까지 불러들여서 화면ì—� ì¶œë ¥í•˜ëŠ” 함수 (OnReadFile()) 함수ì�´ë‹¤.
ìš°ì„ ê¸°ë³¸ì �으로 ë ˆë°�즈ì—�서 ë§µì�„ ì œìž‘í•˜ê²Œ ë�˜ë©´ ë§µì�„ ì €ìž¥í•˜ê¸° 위해서
위ì�˜ OnWriteFile()ì—�서 쓰여진 Open() 함수와 Write() 함수를 쓰게 ë� 것 같다.
ê·¸ë¦¬ê³ ë ˆë°�즈 게임ì�„ 실행하게 ë�˜ë©´ ê·¸ ë§µì�´ ë¶ˆë ¤ì ¸ì•¼ 하므로,
기본ì �ì�¸ Read() 함수ë�„ ì‚¬ìš©í• ê²ƒ 같다.
그러나 ì‹¤ì œ ë ˆë°�즈 게임ì—�서는 txt 파ì�¼ 형ì‹�ì�´ 아니ë�¼ bitmap 형ì‹�으로ì�˜ ì €ìž¥ê³¼ ì�½ê¸°ê°€ 가능해야 하므로,
ê°€ìƒ�화면ì�„ ìƒ�ì„±í•˜ê³ , ê°€ìƒ�화면ì—� 그린것ì�„ 화면으로 ë³µì‚¬í•˜ê³ , ê°€ìƒ�화면ì�„ 지우는 작업등ì�´ 추가 ë�˜ì–´ì•¼ 한다.
ê·¸ 나머지 ê³¼ì •ì�€ ì�¼ë°˜ì �ì�¸ 작업 ë‚´ìš©ì�€ ê±°ì�˜ ë�™ì�¼í•˜ë¯€ë¡œ 기본ì �ì�¸ CFile 부분ì�„ 숙지해야 í• ê²ƒ 같다.
#include "stdafx.h"
#include "FileioView.h"
void CFileioView::OnWritefile()
{
CFile Wfile;
if(!Wfile.Open("TestFile.txt", CFile::modeCreate | CFile::modeWrite))
{
::MessageBox(NULL, "Can't Create testfile.txt !", "Warning", MB_OK | MB_ICONHAND);
return;
}
char* ps = new char[27];
char* ps2 = ps;
for(int i=0;i<26;i++)
*ps2++ = 'A'+i;
*ps2 = NULL; // NULL 문�로 �나게 한다.
Wfile.Write(ps,27);
Wfile.Close();
delete ps;
}
void CFileioView::OnReadfile()
{
CFile Rfile;
if(!Rfile.Open("TestFile.txt", CFile::modeRead))
{
::MessageBox(NULL, "Can't Open testfile.txt !", "Warning",
MB_OK | MB_ICONHAND);
return;
}
UINT FileLength = (UINT)Rfile.GetLength();
char* ps = new char[FileLength];
Rfile.Read(ps,FileLength);
Rfile.Close();
CPaintDC dc(this);
dc.TextOut(0,0,ps,lstrlen(ps));
delete ps;
}
CFile �래스 내� Write() 함수를 �용해서 'A' ~ 'Z' 까지 � 넣는 함수 (OnWriteFile())와,
파ì�¼ì—� 쓰여진 'A' ~ 'Z'까지 불러들여서 화면ì—� ì¶œë ¥í•˜ëŠ” 함수 (OnReadFile()) 함수ì�´ë‹¤.
위ì�˜ OnWriteFile()ì—�서 쓰여진 Open() 함수와 Write() 함수를 쓰게 ë� 것 같다.
ê·¸ë¦¬ê³ ë ˆë°�즈 게임ì�„ 실행하게 ë�˜ë©´ ê·¸ ë§µì�´ ë¶ˆë ¤ì ¸ì•¼ 하므로,
기본ì �ì�¸ Read() 함수ë�„ ì‚¬ìš©í• ê²ƒ 같다.
그러나 ì‹¤ì œ ë ˆë°�즈 게임ì—�서는 txt 파ì�¼ 형ì‹�ì�´ 아니ë�¼ bitmap 형ì‹�으로ì�˜ ì €ìž¥ê³¼ ì�½ê¸°ê°€ 가능해야 하므로,
ê°€ìƒ�화면ì�„ ìƒ�ì„±í•˜ê³ , ê°€ìƒ�화면ì—� 그린것ì�„ 화면으로 ë³µì‚¬í•˜ê³ , ê°€ìƒ�화면ì�„ 지우는 작업등ì�´ 추가 ë�˜ì–´ì•¼ 한다.
ê·¸ 나머지 ê³¼ì •ì�€ ì�¼ë°˜ì �ì�¸ 작업 ë‚´ìš©ì�€ ê±°ì�˜ ë�™ì�¼í•˜ë¯€ë¡œ 기본ì �ì�¸ CFile 부분ì�„ 숙지해야 í• ê²ƒ 같다.










