Hi,
API Declare
<DllImport("she ll32.dll", entrypoint:="SH FileOperationA" , _
setlasterror:=T rue, CharSet:=CharSe t.Auto, exactspelling:= True, _
CallingConventi on:=CallingConv ention.StdCall) > _
Public Shared Function SHFileOperation (ByRef lpFileOp As SHFILEOPSTRUCT) As
Integer
End Function
Structure
Structure SHFILEOPSTRUCT
Dim hwnd As Integer
Dim wFunc As Integer
Dim pFrom As String
Dim pTo As String
Dim fFlags As Short
Dim fAnyOperationsA borted As Integer
Dim hNameMappings As Integer
Dim lpszProgressTit le As String ' only used if FOF_SIMPLEPROGR ESS
End Structure
How To Use
Const FO_COPY = &H2
Const FOF_SIMPLEPROGR ESS = &H100 ' means don't show names of files
Dim foCopy As SHFILEOPSTRUCT
With foCopy
.wFunc = FO_COPY
.pFrom = "C:\Temp" & Chr(0) & Chr(0)
.pTo = "C:\Backup" & Chr(0) & Chr(0)
.fFlags = FOF_SIMPLEPROGR ESS
End With
SHFileOperation (foCopy)
Ken
------------------
"Simon Abolnar" <Si***********@ tscng.net> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I am working on problem of coping folder.
I am using Windows XP/VB.Net 2003
I know how to do it with FileSystemObjec t, but I would like to have copy
dialog between operation like it is in windows explorer.
Is it possible to do this with System.IO (framework)?
I tried to use SHFileOperation (SHFileOP), but something is wrong.
After setting SHFileOp structure like
With SHFileOp
.wFunc = FO_COPY
.pFrom = "C:\Temp" & Chr(0) & Chr(0)
.pTo = "C:\Backup" & Chr(0) & Chr(0)
.fFlags = FOF_SIMPLEPROGR ESS
End With
my program stop with:
An unhandled exception of type 'System.NullRef erenceException ' occurred in
xxx.exe
Additional information: Object reference not set to an instance of an
object.
I don't know where is the problem.
Thanks all for help!!!
Simon