Use this tag for question about SHFileOperation function
Questions tagged [shfileoperation]
35 questions
8
votes
1 answer
Is it safe to use the SHFileOperation in a worker thread?
I would like to have
one background thread which will copy the files through the SHFileOperation function, always only one SHFileOperation at the time (but I want it to be in the thread)
I need the UI output, so I need to use the…

Martin Reiner
- 2,167
- 2
- 20
- 34
8
votes
2 answers
Double null-terminated string
I need to format a string to be double null-terminated string in order to use SHFileOperation.
Interesting part is i found one of the following working, but not both:
// Example 1
CString szDir(_T("D:\\Test"));
szDir = szDir + _T('\0') +…

wengseng
- 1,330
- 1
- 14
- 27
5
votes
0 answers
SHFileOperation much slower in Windows 10 1709
We are finding that deleting folders using SHFileOperation is very slow on systems that have been updated to 1709. It seems like there's something that's crept in related to Universal Windows apps that is causing this.
This code:
sFileOp.wFunc =…

Mark Scarbrough
- 51
- 1
5
votes
2 answers
SHFileOperation works but prints error messages
I'm using Shell API to copy a folder with files.
SHFILEOPSTRUCT sf = {0};
sf.wFunc = FO_COPY;
sf.hwnd = 0;
sf.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_SILENT | FOF_NO_UI;
sf.pFrom =…

Sergi0
- 1,084
- 14
- 28
5
votes
1 answer
SHFileOperation: randomly raises exceptions when deleting files
I am using SHFileOperation() to delete directories from a specific path. It is done in multiple threads and the directory that's deleted is always different.
From time to time, it throws exceptions:
Exception thrown at 0x00007FF8AF5D9D2A…

cydan
- 615
- 5
- 17
3
votes
1 answer
SHFileOperation copying folders using strings
I am trying to copy a folder by SHFileOperationA function. Here is my code.
int main() {
SHFILEOPSTRUCTA sf;
int result;
string source = "D:\\check\\folder4";
string dest = "D:\\Documents\\test\\folder4";
sf.pFrom =…

Prasad
- 5,946
- 3
- 30
- 36
3
votes
2 answers
SHFileOperation FOF_ALLOWUNDO fails on long filenames
I'm using the following function to delete a file to the recycle bin: (C++, MFC, Unicode)
bool DeleteFileToPaperbasket (CString filename)
{
TCHAR Buffer[2048+4];
_tcsncpy_s (Buffer, 2048+4, filename, 2048);
Buffer[_tcslen(Buffer)+1]=0;…

user178379
- 240
- 2
- 11
2
votes
1 answer
Copying directory structure with SHFileOperation failed if FOF_NOERRORUI is requested
I have a working code utilizing SHFileOperation for copying one directory into another. In this case this is Pascal code, but I also have been using the same function in C++, and the problem seems related to Windows core, not a specific programming…

Stan
- 8,683
- 9
- 58
- 102
2
votes
1 answer
SHFileOperation error 87
I am trying to copy the contents of the A drive into folder C:\test\disk1. Folder disk1 already exists. The program compiles but when it runs I get error 87. I know error 87 has something to do with an invalid parameter but Im not sure where the…

Robbie J
- 79
- 1
- 9
2
votes
1 answer
Ignoring exclusively locked files in SHFileOperation
I am using Windows 7 Professional and I am using SHFileOperation() to recursive copy one folder contents to another. But there is a locked file (opened exclusively by an application); I need to skip it, but SHFileOperation() returns 0x20 when tries…

cls
- 501
- 1
- 5
- 18
2
votes
2 answers
SHFileOperation FO_MOVE deletes a file if the destination drive is full
I had a piece of code which uses windows SHFileOperation function with FO_MOVE operation. Additional flags specified were FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT.
A particular weird behavior was observed when the destination drive was full.…

Shailesh Kumar
- 6,457
- 8
- 35
- 60
2
votes
1 answer
SHFileOperation copy with custom progress bar / c++ builder
I use C++ Builder and SHFileOperation to download an application (its folder) from a network location. WinApi has its own progress bar but i need a custom form with a progress bar.
How can i track the copy progress alone so i can have my own…

apo
- 69
- 2
- 9
2
votes
1 answer
In delphi how do I create a string with null separator
I am using SHFileOperation and the source can be a pwidechar with filenames separated by a null and the whole thing terminated with a double null.
I can create an array of widechar and it holds the information I need but when I try to convert to…

Daniel
- 315
- 5
- 16
1
vote
2 answers
Explanation of return code from SHFileOperation()
Is there a reason SHFileOperation() returns 32?
My scenario is:
My current path is c:\foo\bar.
My file is in c:\foo
That file is going to the Recycle Bin.
This code is not listed as possible return value in here, and I don't know where to find the…

Igor
- 5,620
- 11
- 51
- 103
1
vote
1 answer
SHFileOperation doesn't move all of a folder's contents
this makes a new folder on the desktop, but it doesn't move the contents of the folder .pfrom to the folder .pTo.
int main()
{
SHFILEOPSTRUCT sf = {0};
TCHAR myt[MAX_PATH];
GetModuleFileName(NULL, myt, MAX_PATH); // puts the currente…

Geore Shg
- 1,299
- 5
- 23
- 38