Click here to Skip to main content
15,894,825 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: how to get text(caption) associated with IDs in MFC dialog based application? Pin
Purish Dwivedi13-Apr-09 23:35
Purish Dwivedi13-Apr-09 23:35 
GeneralRe: how to get text(caption) associated with IDs in MFC dialog based application? Pin
Divyang Mithaiwala14-Apr-09 0:24
Divyang Mithaiwala14-Apr-09 0:24 
QuestionRe: how to get text(caption) associated with IDs in MFC dialog based application? Pin
David Crow14-Apr-09 3:17
David Crow14-Apr-09 3:17 
QuestionUpdate data in CEDB using C++ and win32 APIs Pin
vijaywithu13-Apr-09 19:00
vijaywithu13-Apr-09 19:00 
QuestionC++ win32 console copy files problems Pin
h2_goh13-Apr-09 17:44
h2_goh13-Apr-09 17:44 
AnswerRe: C++ win32 console copy files problems Pin
flyxie13-Apr-09 19:08
flyxie13-Apr-09 19:08 
GeneralRe: C++ win32 console copy files problems Pin
h2_goh13-Apr-09 20:36
h2_goh13-Apr-09 20:36 
GeneralRe: C++ win32 console copy files problems Pin
flyxie13-Apr-09 20:51
flyxie13-Apr-09 20:51 
// test01.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <string>

using namespace std;
const int BUF_SIZE = 1024;

int main(int argc, char *argv[])
{
HANDLE fileIn, fileOut;
char buf[BUF_SIZE];

DWORD nread,nwrote;
wstring folder1 = L"C:\\firstFolder\\";
wstring folder2 = L"C:\\secondFolder\\";
wstring file1 =L"1.doc";
wstring file2=L"new.doc";
wstring file3=L"2.doc";
wstring file4=L"new2.doc";

wstring folder[] = {folder1, folder2};
int count=0;

for (int i = 0; i < 2; i++)
{
// copy files
if ((fileIn = CreateFile(file1.c_str(), GENERIC_READ,0, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) {
cerr << "Error opening source: " << GetLastError() << endl;
}

if ((fileOut = CreateFile((folder[i] + file2).c_str(), GENERIC_WRITE,0, 0, CREATE_NEW, 0, 0)) == INVALID_HANDLE_VALUE) {
cerr << "Error opening destination: " << GetLastError() << endl;
}
while (ReadFile(fileIn, buf, BUF_SIZE,&nread, NULL) && nread > 0) {
if ( ! WriteFile(fileOut, buf, nread,&nwrote, NULL)) {
cerr << "Error copy" << GetLastError() << endl;
}
}
CloseHandle(fileIn);
CloseHandle(fileOut);

// copy files
if ((fileIn = CreateFile(file3.c_str(), GENERIC_READ,0, 0, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) {
cerr << "Error opening source: " << GetLastError() << endl;
}

if ((fileOut = CreateFile((folder[i] + file4).c_str(), GENERIC_WRITE,0, 0, CREATE_NEW, 0, 0)) == INVALID_HANDLE_VALUE) {
cerr << "Error opening destination: " << GetLastError() << endl;
}
while (ReadFile(fileIn, buf, BUF_SIZE,&nread, NULL) && nread > 0) {
if ( ! WriteFile(fileOut, buf, nread,&nwrote, NULL)) {
cerr << "Error copy" << GetLastError() << endl;
}
}
CloseHandle(fileIn);
CloseHandle(fileOut);
}
return 0;
}
AnswerRe: C++ win32 console copy files problems Pin
KarstenK13-Apr-09 21:40
mveKarstenK13-Apr-09 21:40 
GeneralRe: C++ win32 console copy files problems Pin
Iain Clarke, Warrior Programmer14-Apr-09 3:52
Iain Clarke, Warrior Programmer14-Apr-09 3:52 
QuestionHelp with a simple phone book program Pin
Subrina Bisnauth13-Apr-09 13:20
Subrina Bisnauth13-Apr-09 13:20 
AnswerRe: Help with a simple phone book program Pin
David Crow13-Apr-09 15:42
David Crow13-Apr-09 15:42 
QuestionC++ Socket/Multithread Programming Question Pin
djcouture13-Apr-09 9:18
djcouture13-Apr-09 9:18 
AnswerRe: C++ Socket/Multithread Programming Question Pin
bulg13-Apr-09 12:05
bulg13-Apr-09 12:05 
GeneralRe: C++ Socket/Multithread Programming Question Pin
djcouture14-Apr-09 3:29
djcouture14-Apr-09 3:29 
GeneralRe: C++ Socket/Multithread Programming Question Pin
bulg14-Apr-09 7:32
bulg14-Apr-09 7:32 
GeneralRe: C++ Socket/Multithread Programming Question Pin
djcouture15-Apr-09 5:27
djcouture15-Apr-09 5:27 
QuestionInternet to USB application Pin
2buck5613-Apr-09 9:17
2buck5613-Apr-09 9:17 
AnswerRe: Internet to USB application Pin
bulg13-Apr-09 12:08
bulg13-Apr-09 12:08 
GeneralRe: Internet to USB application Pin
2buck5613-Apr-09 13:04
2buck5613-Apr-09 13:04 
QuestionMore specific question, help please Pin
bulg13-Apr-09 14:32
bulg13-Apr-09 14:32 
AnswerRe: More specific question, help please Pin
2buck5613-Apr-09 15:58
2buck5613-Apr-09 15:58 
AnswerRe: Internet to USB application Pin
Iain Clarke, Warrior Programmer14-Apr-09 4:02
Iain Clarke, Warrior Programmer14-Apr-09 4:02 
GeneralRe: Internet to USB application Pin
2buck5614-Apr-09 5:01
2buck5614-Apr-09 5:01 
QuestionSet Class - Insert Function Pin
aab1990213-Apr-09 7:28
aab1990213-Apr-09 7:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.