Verschieben von Dateinen

natsu1000

Grünschnabel
habe mal wieder ein Problem

#include <stdafx.h>
#include <iostream>
#include <string>
#include <conio.h>

using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
const string copy = "copy ";
char cPath[255];
string sPath;
string aPath;
char cFolderName[255];
char cFolderNameNew[255];
char cNumber[255];
string sCommand;
string sCommanda;



// Pfad einlesen
cout << "Wo ist der alte Ordner gespeichert?" << endl;
cin.getline(cPath, 255);

sPath = cPath;

// Wenn am Ende des Pfades kein \ ist, füge es hinzu
if (sPath[sPath.length() - 1] != '\\')
{
sPath = sPath + "\\";
}


// Ordnername einlesen
cout << "Wie heist der alte Ordner?" << endl;
cin.getline(cFolderName, 255);

// Pfad einlesen
cout << "Wo soll der neue Ordner hin?" << endl;
cin.getline(cPath, 255);

aPath = cPath;

// Wenn am Ende des Pfades kein \ ist, füge es hinzu
if (aPath[aPath.length() - 1] != '\\')
{
aPath = aPath + "\\";
}





// Ordner erstellen
int i=1;



itoa(i, cNumber, 10);

sCommand = copy + "\"" + sPath + cFolderName "\"" + "\"" + aPath + "\"";

// Ordner erstellen
cout<<sCommand;

//system(sCommand.c_str());


cout << endl << "Fertig!" << endl << endl;

getch();
return 0;
}


Die fett makierte Zeile funktioniert so nicht. :mad: :mad:
Das Programm soll nach eingabe von
d: hallo.doc d:help
die datei hallo.doc nach d:help kopieren. doch mit der Pfadeingabe,die variabel bleiben soll, funktioniert so noch nicht.
Kann jemand helfen:confused:
 
1. Du solltest Deinen Code in Code-Tags einschließen und einrücken, dann ist es einfacher, ihn zu lesen und es macht mehr Spaß, Dir zu helfen.

2. Zu deinem Problem:
Du kannst keinen Zeiger zu einem string addieren. Das mußt Du so machen:
Code:
sCommand = copy + string("\"") + sPath + cFolderName + string("\"") + string(" \"") + aPath + string("\"");
 
Zurück