{vb} bestand verplaatsen/copy

Pagina: 1
Acties:

  • Ronald_stage
  • Registratie: Januari 2002
  • Laatst online: 11-09 21:45

Ronald_stage

wat kan je hier nog zeggen

Topicstarter
ik wil alle bestanden uit een directory verplaatsen of kopieen

dus in dos zou het zijn copy c:\input\. c:\output\
maar nu in VB
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Private Sub Command2_Click()
On Error GoTo ErrHandler

FileCopy "c:\input\.", "c:\output\"




Exit Sub

ErrHandler:

    MsgBox Err.Description

End Sub

dit werkt niet
want je moet het doel bestand opgeven, en je kan geen wildcards gebruiken

nu is er ook iets met FSO maar dat snap ik nog niet helemaal.

enig advies? Links?
BvD

  • baskabas
  • Registratie: December 2000
  • Laatst online: 05-04 12:26
Werkt *.* niet?

Anders moet je een loopje maken en de Dir functie gebruiken...

Zoiets als
code:
1
2
3
4
5
6
strBron = Dir("c:\input\*.*")

Do While strBron <> ""
  FileCopy "c:\input\" & strBron, "c:\output\" & strBron
  strBron = Dir("c:\input\*.*")
Loop

Dir functie geeft dan alle files 1 voor 1 door.

(strings voor dirs natuurlijk wel ff in variabelen zetten...)

Suc6! ;)

Verwijderd

Het kan veel netter met de SHFileOperation api. Met een SHFILEOPSTRUCT type moet je dan even de source, destination, flags en action opgeven en t gaat in een keer :)

  • Basszje
  • Registratie: Augustus 2000
  • Laatst online: 15-09 11:04

Basszje

Reisvaap!]

Kan je beter dan met FileSystemObject doen idd ( fan van FSO :P ) .


Check anders even op www.devguru.com hoe je precies FileSystemObject gebruikt. :)

Beware of listening to the imposter; you are undone if you once forget that the fruits of the earth belong to us all, and the earth itself to nobody.