problem in using SHFILEOPSTRUCT and SHFileOperation









up vote
-1
down vote

favorite












I am trying to use the SHFileOperation() function to copy a folder from one directory to another directory.



I wrote the below code using this link: Copy a Folder.



But I get error code 0x7B, and when I searched for information about the error, this page says: "The filename, directory name, or volume label syntax is incorrect."



I wrote the filename and directory name correctly, but I don't know why this code can't copy the ty folder from the D drive to another folder called secondfolder on the D drive.



Sorry, I searched about this a lot in your website, but I didn't get any answer to my issue.



#include <iostream>
#include <Windows.h>

using namespace std;

int main()

system("color 0A")
SHFILEOPSTRUCT fo;
memset(&fo, 0, sizeof(fo));
fo.hwnd = 0;
fo.wFunc = FO_COPY;
fo.pFrom = L"D:\ty\*";
fo.pTo = L"D:\secondfolder\*";
fo.fFlags = FOF_NOCONFIRMMKDIR









share|improve this question























  • @AlexF read the documentation. Extra null terminators are required on pTo and pFrom, as they are double null terminated lists. fo.pFrom = L"D:\ty\*"; fo.pTo = L"D:\secondfolder\";
    – Remy Lebeau
    Nov 11 at 6:32














up vote
-1
down vote

favorite












I am trying to use the SHFileOperation() function to copy a folder from one directory to another directory.



I wrote the below code using this link: Copy a Folder.



But I get error code 0x7B, and when I searched for information about the error, this page says: "The filename, directory name, or volume label syntax is incorrect."



I wrote the filename and directory name correctly, but I don't know why this code can't copy the ty folder from the D drive to another folder called secondfolder on the D drive.



Sorry, I searched about this a lot in your website, but I didn't get any answer to my issue.



#include <iostream>
#include <Windows.h>

using namespace std;

int main()

system("color 0A")
SHFILEOPSTRUCT fo;
memset(&fo, 0, sizeof(fo));
fo.hwnd = 0;
fo.wFunc = FO_COPY;
fo.pFrom = L"D:\ty\*";
fo.pTo = L"D:\secondfolder\*";
fo.fFlags = FOF_NOCONFIRMMKDIR









share|improve this question























  • @AlexF read the documentation. Extra null terminators are required on pTo and pFrom, as they are double null terminated lists. fo.pFrom = L"D:\ty\*"; fo.pTo = L"D:\secondfolder\";
    – Remy Lebeau
    Nov 11 at 6:32












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I am trying to use the SHFileOperation() function to copy a folder from one directory to another directory.



I wrote the below code using this link: Copy a Folder.



But I get error code 0x7B, and when I searched for information about the error, this page says: "The filename, directory name, or volume label syntax is incorrect."



I wrote the filename and directory name correctly, but I don't know why this code can't copy the ty folder from the D drive to another folder called secondfolder on the D drive.



Sorry, I searched about this a lot in your website, but I didn't get any answer to my issue.



#include <iostream>
#include <Windows.h>

using namespace std;

int main()

system("color 0A")
SHFILEOPSTRUCT fo;
memset(&fo, 0, sizeof(fo));
fo.hwnd = 0;
fo.wFunc = FO_COPY;
fo.pFrom = L"D:\ty\*";
fo.pTo = L"D:\secondfolder\*";
fo.fFlags = FOF_NOCONFIRMMKDIR









share|improve this question















I am trying to use the SHFileOperation() function to copy a folder from one directory to another directory.



I wrote the below code using this link: Copy a Folder.



But I get error code 0x7B, and when I searched for information about the error, this page says: "The filename, directory name, or volume label syntax is incorrect."



I wrote the filename and directory name correctly, but I don't know why this code can't copy the ty folder from the D drive to another folder called secondfolder on the D drive.



Sorry, I searched about this a lot in your website, but I didn't get any answer to my issue.



#include <iostream>
#include <Windows.h>

using namespace std;

int main()

system("color 0A")
SHFILEOPSTRUCT fo;
memset(&fo, 0, sizeof(fo));
fo.hwnd = 0;
fo.wFunc = FO_COPY;
fo.pFrom = L"D:\ty\*";
fo.pTo = L"D:\secondfolder\*";
fo.fFlags = FOF_NOCONFIRMMKDIR






c++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 6:28









Remy Lebeau

327k18246433




327k18246433










asked Nov 11 at 4:52









meysamimani

1




1











  • @AlexF read the documentation. Extra null terminators are required on pTo and pFrom, as they are double null terminated lists. fo.pFrom = L"D:\ty\*"; fo.pTo = L"D:\secondfolder\";
    – Remy Lebeau
    Nov 11 at 6:32
















  • @AlexF read the documentation. Extra null terminators are required on pTo and pFrom, as they are double null terminated lists. fo.pFrom = L"D:\ty\*"; fo.pTo = L"D:\secondfolder\";
    – Remy Lebeau
    Nov 11 at 6:32















@AlexF read the documentation. Extra null terminators are required on pTo and pFrom, as they are double null terminated lists. fo.pFrom = L"D:\ty\*"; fo.pTo = L"D:\secondfolder\";
– Remy Lebeau
Nov 11 at 6:32




@AlexF read the documentation. Extra null terminators are required on pTo and pFrom, as they are double null terminated lists. fo.pFrom = L"D:\ty\*"; fo.pTo = L"D:\secondfolder\";
– Remy Lebeau
Nov 11 at 6:32












1 Answer
1






active

oldest

votes

















up vote
0
down vote













You need to remove the * from pTo:



fo.pTo = L"D:\secondfolder\";


Also, you are trying to copy only the contents of ty, not copy ty itself. If you want that, remove the * from pFrom as well:



fo.pFrom = L"D:\ty\";





share|improve this answer




















  • thank you so much dear Remy Lebeau
    – meysamimani
    Nov 11 at 13:45










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245950%2fproblem-in-using-shfileopstruct-and-shfileoperation%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













You need to remove the * from pTo:



fo.pTo = L"D:\secondfolder\";


Also, you are trying to copy only the contents of ty, not copy ty itself. If you want that, remove the * from pFrom as well:



fo.pFrom = L"D:\ty\";





share|improve this answer




















  • thank you so much dear Remy Lebeau
    – meysamimani
    Nov 11 at 13:45














up vote
0
down vote













You need to remove the * from pTo:



fo.pTo = L"D:\secondfolder\";


Also, you are trying to copy only the contents of ty, not copy ty itself. If you want that, remove the * from pFrom as well:



fo.pFrom = L"D:\ty\";





share|improve this answer




















  • thank you so much dear Remy Lebeau
    – meysamimani
    Nov 11 at 13:45












up vote
0
down vote










up vote
0
down vote









You need to remove the * from pTo:



fo.pTo = L"D:\secondfolder\";


Also, you are trying to copy only the contents of ty, not copy ty itself. If you want that, remove the * from pFrom as well:



fo.pFrom = L"D:\ty\";





share|improve this answer












You need to remove the * from pTo:



fo.pTo = L"D:\secondfolder\";


Also, you are trying to copy only the contents of ty, not copy ty itself. If you want that, remove the * from pFrom as well:



fo.pFrom = L"D:\ty\";






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 6:38









Remy Lebeau

327k18246433




327k18246433











  • thank you so much dear Remy Lebeau
    – meysamimani
    Nov 11 at 13:45
















  • thank you so much dear Remy Lebeau
    – meysamimani
    Nov 11 at 13:45















thank you so much dear Remy Lebeau
– meysamimani
Nov 11 at 13:45




thank you so much dear Remy Lebeau
– meysamimani
Nov 11 at 13:45

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245950%2fproblem-in-using-shfileopstruct-and-shfileoperation%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto