Hi everyone, I am trying to move files from one folder (server 1) to another folder(server 2) through command xcopy . I am using the editor dev c++. My code works fine if i have to move file within single server but gives error " Invalid parameters " if i am trying between servers.
Here is the code
int main(int argc, char *argv[]) {
time_t start, stop;
clock_t ticks; long count;
time(&start);
int i=0;
while(1)
{
time(&stop);
if(difftime(stop, start)== 60) // moving file after every one min
{
//abc is my folder and have to move to test folder of another server
//have replaced server name wid server 1 and 2
Destination : Specifies the destination of the files you want to copy. This parameter can include a drive letter and colon, a directory name, a file name, or a combination of these.
It doesn't state that you can copy it from server to server. Only from drive to drive.
I doubt that any console command is capable of handling network paths that aren't mapped to a drive letter.
I've had some really bad side-effect from trying to run a .bat file when I wasn't on a mapped network path. The shell defaulted to open in the c:\windows, I was running as admin and the bat file contained del /S *.exe. Well you might guess the result...
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
EDIT:
OR you can do as Igor suggest in the next post...
BUT
also agree with VictorN...I find SHFileOperation easier to use within C++ than a "system" call plus you can also get a progress bar for the file operation. Give SHFileOperation a try...if you need help just give a shout for a sample...
HTH...
Last edited by Vanaj; May 4th, 2012 at 12:48 AM.
Reason: tech...
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
When I got my fingers badly burned I was running XP so I guess you run Win7?
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
Nope. It's Windows XP SP3, and you take my word I did this even back in Windows NT4 ages.
The real difference between the cases, mine and yours, is that mine has paths fully specified while yours might rely on current directory. The latter really must be set to some letter drive based path, otherwise it's %WINDIR%\system32 that automatically implied.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
Bookmarks