W
WolfgangS
Ok first off, i am a total beginner at this groups stuff and i have no
clue how this works. This is probabaly the wrong group for my problem
but i will post it anyways. Learning by doing right?
I will post a code snippet and explain my problem. I cant seem to find
a logical explanation why this problem would occur after trying to
figure it out for a few hours. However I am probably just blind and/or
stupid and you will realise where i go wrong at first glance. Using
Borland C++ Builder 6 btw.
This might get a bit long and it might be in the wrong group but it
also might be interesting. So...uhm....read it
SHFILEOPSTRUCT sfo = {0};
//-- Part 1:-----------------------------
m_PLCDest = m_PLCDest + "\\Vorbereitung\\";
CreateDir ( m_PLCDest );
sfo.wFunc = FO_COPY;
sfo.pFrom = m_PLCSource.c_str();
sfo.pTo = m_PLCDest.c_str();
sfo.fFlags = FOF_SIMPLEPROGRESS | FOF_NOCONFIRMATION |
FOF_NOCONFIRMMKDIR | FOF_RENAMEONCOLLISION;
SHFileOperation (&sfo);
// End Part 1-------------------------
//-- Part 2:--------------------------------
sfo.wFunc = FO_COPY;
sfo.pFrom = "J:\\PROGRAMM\\Beckhoff\\A_NeuerKunde\\ABxxxxx\
\Sys_Manager";
sfo.pTo = m_PLCDest.c_str();
sfo.fFlags = FOF_SIMPLEPROGRESS | FOF_NOCONFIRMATION |
FOF_NOCONFIRMMKDIR | FOF_RENAMEONCOLLISION;
SHFileOperation (&sfo);
//End Part 2-------------------------------
//-- Part 3: --------------------------------
strDestParam = strDestParam + "\\visfil3";
sfo.wFunc = FO_MOVE;
sfo.pFrom = strDestParam.c_str();
sfo.pTo = m_PLCDest.c_str();
sfo.fFlags = FOF_SIMPLEPROGRESS | FOF_NOCONFIRMATION |
FOF_NOCONFIRMMKDIR | FOF_RENAMEONCOLLISION;
SHFileOperation (&sfo);
//End Part 3-------------------------------
As you can see i am using SHFileOperation and SHFILEOPSTRUCT to copy
or move a few directories. Now what happens is the following. When i
execute the code, Part 1 works fine. Then in Part 2 i get an error
message saying "File cant be copied. Cant read sourcefile or cant read
from the source data carrier" (Freely translated from german). I click
away the error message. After that Part 3 is executed without
problems. BTW: All the directories I am trying to copy/move are on a
network drive which is mapped as J: on my PC.
Now comes the interesting part. If i remove part 3, part 1 and 2 work
perfectly. If I execute part 3 before part 2 ( meaning i simply cut
and paste the code of part 3 between part 1 and 2 all 3 parts work
fine. I have tried various other combinations and came to the
conclusion that it only works if part 2 is actually the last part to
be executed.
How can this be? How can code which has not even been executed (part 3
in this example) produce an error in previous code that works fine
otherwise.
Code should be executed line by line right?
Also you dont need to worry too much about the actual code. I simply
want to have an explanation how the existence of part 3 can have an
impact on the execution of part 2.
Any ideas?
Thanks to those who actually read this.
clue how this works. This is probabaly the wrong group for my problem
but i will post it anyways. Learning by doing right?
I will post a code snippet and explain my problem. I cant seem to find
a logical explanation why this problem would occur after trying to
figure it out for a few hours. However I am probably just blind and/or
stupid and you will realise where i go wrong at first glance. Using
Borland C++ Builder 6 btw.
This might get a bit long and it might be in the wrong group but it
also might be interesting. So...uhm....read it
SHFILEOPSTRUCT sfo = {0};
//-- Part 1:-----------------------------
m_PLCDest = m_PLCDest + "\\Vorbereitung\\";
CreateDir ( m_PLCDest );
sfo.wFunc = FO_COPY;
sfo.pFrom = m_PLCSource.c_str();
sfo.pTo = m_PLCDest.c_str();
sfo.fFlags = FOF_SIMPLEPROGRESS | FOF_NOCONFIRMATION |
FOF_NOCONFIRMMKDIR | FOF_RENAMEONCOLLISION;
SHFileOperation (&sfo);
// End Part 1-------------------------
//-- Part 2:--------------------------------
sfo.wFunc = FO_COPY;
sfo.pFrom = "J:\\PROGRAMM\\Beckhoff\\A_NeuerKunde\\ABxxxxx\
\Sys_Manager";
sfo.pTo = m_PLCDest.c_str();
sfo.fFlags = FOF_SIMPLEPROGRESS | FOF_NOCONFIRMATION |
FOF_NOCONFIRMMKDIR | FOF_RENAMEONCOLLISION;
SHFileOperation (&sfo);
//End Part 2-------------------------------
//-- Part 3: --------------------------------
strDestParam = strDestParam + "\\visfil3";
sfo.wFunc = FO_MOVE;
sfo.pFrom = strDestParam.c_str();
sfo.pTo = m_PLCDest.c_str();
sfo.fFlags = FOF_SIMPLEPROGRESS | FOF_NOCONFIRMATION |
FOF_NOCONFIRMMKDIR | FOF_RENAMEONCOLLISION;
SHFileOperation (&sfo);
//End Part 3-------------------------------
As you can see i am using SHFileOperation and SHFILEOPSTRUCT to copy
or move a few directories. Now what happens is the following. When i
execute the code, Part 1 works fine. Then in Part 2 i get an error
message saying "File cant be copied. Cant read sourcefile or cant read
from the source data carrier" (Freely translated from german). I click
away the error message. After that Part 3 is executed without
problems. BTW: All the directories I am trying to copy/move are on a
network drive which is mapped as J: on my PC.
Now comes the interesting part. If i remove part 3, part 1 and 2 work
perfectly. If I execute part 3 before part 2 ( meaning i simply cut
and paste the code of part 3 between part 1 and 2 all 3 parts work
fine. I have tried various other combinations and came to the
conclusion that it only works if part 2 is actually the last part to
be executed.
How can this be? How can code which has not even been executed (part 3
in this example) produce an error in previous code that works fine
otherwise.
Code should be executed line by line right?
Also you dont need to worry too much about the actual code. I simply
want to have an explanation how the existence of part 3 can have an
impact on the execution of part 2.
Any ideas?
Thanks to those who actually read this.