Je veux déplacer le fichier en utilisant le fichier batch, pour cela j'utilise le code ci-dessous le processus semble être exécuté avec succès, mais le fichier ne sont pas transférés. Quelque chose ne va pas avec ce code?Exécuter le fichier batch dans VC++
STARTUPINFO osi;
PROCESS_INFORMATION pi;
ZeroMemory(&osi, sizeof(osi));
osi.cb = sizeof(capinfo);
ZeroMemory(&pi, sizeof(pi));
wchar_t cmd[8192];
wchar_t ocmd[8192];
char ocmd1[8192];
swprintf_s(ocmd,sizeof(ocmd),L"%s\\%s.bat",capodd->templocation,capodd->wcurrentoutput);
sprintf_s(ocmd1,sizeof(ocmd1),"%ls\\%s.bat",capodd->templocation,capodd->currentoutput);
FILE * tempbat = fopen(ocmd1,"w");
swprintf_s(cmd,8192,L"move %s\\%s.mp4 %s\\%s.mp4",capodd->templocation,capodd->wcurrentoutput,capodd->destination,capodd->wcurrentoutput);
fprintf(tempbat,"%ls\n",cmd);
//swprintf_s(cmd,8192,L"move %s\\%s.txt %s\\%s.txt",capodd->templocation,capodd->currentoutput,capodd->destination,capodd->currentoutput);
//fprintf(tempbat,"%ls\n",cmd);
//fprintf(tempbat,"del %ls\n",ocmd);
fclose(tempbat);
swprintf_s(cmd,sizeof(cmd),L"cmd /c %s",ocmd);
// just for fun, sleep for twice my latency to make sure the other half of the graph has started
Sleep(1000 *2); // of course, this means our overlap better be within 2x of the periodicity
if (!CreateProcess(NULL,cmd,NULL,NULL,FALSE,0,NULL,NULL,&osi,&pi)) {
fprintf(capodd->c_pF,"couldn't execute copy %d\n",GetLastError());
}
merci @A. Danesh pour votre réponse, en fait question était que le fichier était utilisé par un autre processus et bcoz de cela, il n'était pas le transfert de fichier. – meghana