Kopieren von Files ohne Overwrite Rückfrage

30/10/2007 - 09:50 von Sebastian Schelker | Report spam
Hallo NG'ler

Ich arbeite mit A00 win XP an einer ProdukteDB.

Ich habe einen Code von einem NG'ler zum kopieren von files:

Option Explicit

Public FO_FUNC As Long
Const FileMove As Integer = 1
Const FileCopy As Integer = 2
Const optSilent As Integer = 0
Const optNoFilenames As Integer = 1
Const optNoConfirmDialog As Integer = 2
Const optRenameIfExists As Integer = 3
Const optPromptMeFirst As Integer = 4
Public Source As String
Public destination As String

Public Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type

Public Const FO_MOVE = &H1
Public Const FO_COPY = &H2
Public Const FO_DELETE = &H3
Public Const FO_RENAME = &H4

Public Const FOF_SILENT = &H4
Public Const FOF_RENAMEONCOLLISION = &H8
Public Const FOF_NOCONFIRMATION = &H10
Public Const FOF_SIMPLEPROGRESS = &H100
Public Const FOF_ALLOWUNDO = &H40

Public Declare Function SHFileOperation Lib "shell32.dll" Alias
"SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias
"SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String)
As Long
Public Declare Function SHGetSpecialFolderLocation Lib
"shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As
Long) As Long
Public Declare Function SHBrowseForFolder Lib "shell32.dll" Alias
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long

Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Public Const NOERROR = 0
Public Const CSIDL_DESKTOP = &H0
Public Const BIF_RETURNONLYFSDIRS = &H1
Public Const BIF_STATUSTEXT = &H4
Public Const BIF_RETURNFSANCESTORS = &H8

Public FLAG&

Public Sub Kopiere(ByVal Source$, ByVal Dest$)

Dim FOF_FLAGS, a As Long
Dim SHFileOp As SHFILEOPSTRUCT

Source = Source & Chr$(0) & Chr$(0)

FOF_FLAGS = FLAG

With SHFileOp
.wFunc = 2
.pFrom = Source
.pTo = Dest
.fFlags = FOF_FLAGS
End With

a = SHFileOperation(SHFileOp)

End Sub

Kann mir jemand sagen, wie ich den Code verànder muss damit nicht
Rückgefragt wird von Windows ob das File überschrieben werden soll?

Gruss
Sebastian
 

Lesen sie die antworten

#1 Mark Doerbandt
30/10/2007 - 09:59 | Warnen spam
Hallo, Sebastian,

Sebastian Schelker:

FOF_FLAGS = FLAG



' http://vbnet.mvps.org/index.html?co...eopadv.htm
'File Operation Flags
Private Const FOF_MULTIDESTFILES As Long = &H1
Private Const FOF_CONFIRMMOUSE As Long = &H2
Private Const FOF_SILENT As Long = &H4
'don't create progress/report Private Const FOF_RENAMEONCOLLISION As
Long = &H8
Private Const FOF_NOCONFIRMATION As Long = &H10
'don't prompt the user.
Private Const FOF_WANTMAPPINGHANDLE As Long = &H20
'Fill in SHFILEOPSTRUCT.hNameMappings
'Must be freed using SHFreeNameMappings
Private Const FOF_ALLOWUNDO As Long = &H40
Private Const FOF_FILESONLY As Long = &H80
'on *.*, do only files
Private Const FOF_SIMPLEPROGRESS As Long = &H100
'don't show names of files
Private Const FOF_NOCONFIRMMKDIR As Long = &H200
'don't confirm making any needed dirs
Private Const FOF_NOERRORUI As Long = &H400
'don't put up error UI
Private Const FOF_NORECURSION As Long = &H1000
'don't recurse into directories
Private Const FOF_NOCOPYSECURITYATTRIBS As Long = &H800
'don't copy NT file Security Attributes
Private Const FOF_NO_CONNECTED_ELEMENTS As Long = &H2000
'Shell v5+: don't operate on connected file elements
Private Const FOF_WANTNUKEWARNING As Long = &H4000
'Shell v5+: during delete operation,
'warn if 'nuking instead of recycling (partially
'overrides FOF_NOCONFIRMATION)
Private Const FOF_NORECURSEREPARSE As Long = &H8000&
'Shell v5.1+: treat reparse points as
'objects, not containers

hast Du denn mal FOF_NOCONFIRMATION probiert?

Gruss - Mark

Informationen fuer Neulinge in den Access-Newsgroups unter
http://www.doerbandt.de/Access/Newbie.htm

Bitte keine eMails auf Newsgroup-Beitràge senden.

Ähnliche fragen