How to disable the confirmation dialog box?

by using the following source code, i found that it take a lot of time to do the files deletion.

Is there any setting that i could set to speed up the process? please do help me. thank you

Private Type SHFILEOPTSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As Long
End Type

Private Declare Function SHFileOperation Lib "Shell32.dll" _
Alias "SHFileOperationA" (lpFileOp As SHFILEOPTSTRUCT) As Long

Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40

Public Sub DeleteFileToRecycleBin(Filename As String)

Dim fop As SHFILEOPTSTRUCT

With fop
.wFunc = FO_DELETE
.pFrom = Filename
.fFlags = FOF_ALLOWUNDO
End With

SHFileOperation fop

End Sub

thanks

[955 byte] By [wtkm] at [2007-12-28]
# 1

Include the FOF_NOCONFIRMATION flag.

MattiasSj?gren at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

Thanks.

I found that, using the source code to delete the files (i have alot of file need to delete, delete the file one by one) to recycle bin does take a long time to process. Anyone have the idea how to speed up the deleting process?

please ... thanks

wtkm at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

wtkm,

Use the File.Delete method. The following code shows how to delete a file and ths method is new in .NET Framework 2.0:

Imports System

Imports System.IO

Imports System.Text

Public Class Test

Public Shared Sub Main()

Dim path As String = "c:\temp\MyTest.txt"

Try

Dim sw As StreamWriter = File.CreateText(path)

sw.Close()

Dim path2 As String = path + "temp"

' Ensure that the target does not exist.

File.Delete(path2)

' Copy the file.

File.Copy(path, path2)

Console.WriteLine("{0} was copied to {1}.", path, path2)

' Delete the newly created file.

File.Delete(path2)

Console.WriteLine("{0} was successfully deleted.", path2)

Catch e As Exception

Console.WriteLine("The process failed: {0}", e.ToString())

End Try

End Sub

End Class

BrunoYu-MSFT at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4
Bruno Yu - MSFT wrote:

Use the File.Delete method. The following code shows how to delete a file and ths method is new in .NET Framework 2.0:

File.Delete was available in 1.0. It does not, however, support moving a file to the Recycle Bin. It will remove it permanently.

MattiasSj?gren at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...