12. april 2004 - 20:01Der er
3 kommentarer og 2 løsninger
kopiere end hvilken som helst fil uden at overskrive en anden
Halløjsa sømand... Nu har jeg brug for hjælp!!! Hvordan kan man kopiere en fil ind i en mappe uden at skulle overskrive en anden med samme navn. Det er den eneste anden fremgangsmåde, som jeg har fået til at virke, men hvis jeg har lavet et program der skal kopiere filer ind i en mappe, hvor der ikke er nogle filer med samme navn... Hvordan kan man gøre det???
Private Sub Form_Load() Call KopierFile("C:\AUTOEXEC.BAT", "C:\AUTOEXEC.BAT") End Sub
Public Sub KopierFile(ByVal strSrc As String, ByVal strDst As String) Dim intDot As Integer Dim intCount As Integer Dim strPath As String If Len(Dir(strDst, 7)) Then strPath = strDst intDot = (InStrRev(strPath, ".") - 1) If intDot > -1 Then Do Until Dir(strDst, 7) = "" intCount = (intCount + 1) strDst = Left$(strPath, intDot) & intCount & _ Right$(strPath, (Len(strPath) - intDot)) Loop Else Do Until Dir(strDst, 7) = "" intCount = (intCount + 1) strDst = (strPath & intCount) Loop End If End If Call FileCopy(strSrc, strDst) End Sub '---------------------------- Form1 ----------------------------
Public Function kopier (Source as String, Destination as String) If len(Dir(Destination)) > 0 then 'filen findes allerede if msgbox("Filen findes allerede!" & vbnewline & "Overskriv?", vbquestion+vbyesno, "Overskriv?") = vbno then exit function endif endif filecopy Source, Destination end function
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.