Avatar of surajguptha
surajguptha
Flag for United States of America

asked on 

Error in SHFileOperation in Shell32.dll

Import code
-------------
[DllImport("shell32.dll" , CharSet = CharSet.Unicode)]
            public static extern Int32 SHFileOperation(
                  ref SHFILEOPSTRUCT lpFileOp);
Actual Code
--------------
totalPathToNetHood="C:\Documents and Settings\suraj_guptha\NetHood"
SHFILEOPSTRUCT FileOpStruct = new SHFILEOPSTRUCT();

FileOpStruct.wFunc = 3;
FileOpStruct.fFlags = 16;
FileOpStruct.pFrom = Marshal.StringToHGlobalUni(totalPathToNetHood);
Int32 a =SHFileOperation(ref FileOpStruct);

The Problem
--------------
I have a small problem with running the script for deleting the files in nethood folder. When i run the actual command it throws an error like

"Cannot Delete File: Cannot read source file or disk"

I happens only on select machines.

This happens when i call Int32 a =SHFileOperation(ref FileOpStruct);

It is not an exception. It just displays the messagebox

Microsoft Development

Avatar of undefined
Last Comment
surajguptha

8/22/2022 - Mon