|
예성곤 님이 쓰신 글 :
원형 :
CopyFile( LPCSTR lpExistingFileName, LPCTSTR lpNewFileName, BOOL bFailIfExists );
특징 :
1번째 인자값에 있는 파일을 2번째 인자값의 경로에 복사한다.
예제 :
#include<windows.h>
CopyFile(m_cNowPath,m_cTargetPath,false);
부가설명 :
m_cNowPath에 있는 파일을 m_cTargetPath 에 복사한다.
이미 파일이 있을때 그 파일을 보존하는것 ( 즉 덮어쓰기 안한다. )
false 일 경우엔 해당경로에 파일이 존재 하더라도 그 파일 위에 덮어쓴다.
: copyfile(a,b,1) 과
: copyfile(a,b,0) 의 차이는 무엇인가요?
:
: 아래와 같이 코딩하였는데...
:
: int i;
: UnicodeString O_file, S_file, show_message;
:
: OpenDialog1->Filter = "All files (*.*)|*.*";
:
: if (OpenDialog1->Execute())
: if (FileExists(OpenDialog1->FileName)) {
: O_file = OpenDialog1->FileName;
: }
: else {
: throw(Exception("파일을 찾을수 없다."));
: return;
: }
:
: if (SaveDialog1->Execute()) {
: if (FileExists(SaveDialog1->FileName)) {
: show_message = SaveDialog1->FileName + "\n\n이미 존재하는 파일입니다. 덮어쓰기를 하시겠습니까?";
: if (MessageDlg(show_message, mtConfirmation,TMsgDlgButtons() << mbYes << mbNo << mbCancel,0) != mrYes ) {
: return;
: }
: }
:
: S_file = SaveDialog1->FileName;
:
: if (CopyFile(O_file.w_str(), S_file.w_str(), 0) == true) {
: MessageDlg (SaveDialog1->FileName + "\n\n파일을 복사하였습니다.", mtInformation, TMsgDlgButtons()<<mbOK,0);
: }
: else {
: throw(Exception(SaveDialog1->FileName + "\n\n파일을 복사할 수 없습니다. 시스템 쓰기 권한을 체크하시기 바랍니다."));
: return;
: }
:
: }
:
: ============================
:
: if (CopyFile(O_file.w_str(), S_file.w_str(), 0) == true) 부분에서
:
: 0을 붙이면 오버라이트가 되고
: 1을 붙이면 오버라이트가 안됩니다.
:
: 어떤 차이가 있나요?
:
:
:
|