USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  Copy pasta e sub pasta e os arquivos
Edson
SÃO PAULO
SP - BRASIL
Postada em 11/08/2004 18:38 hs            
bom noite a todos eu preciso de uma ajuda de vcs, eu precisso fazer um programinha que faz copy de um pasta e sub pasta e todos os arquivo. e que eu fazo coletania de jogos em cd, e ele rada direto no cd, fazer um programinha que copy a pasta e sub pasta e todos os arquivos para "HD" peguei uma Project aqui no vbweb só que ele só copy 1 "UM" arquivo.
exp
 
'************************************************************************
'Coded by   : Nabhan Ahmed
'Date       : 8-25-2003
'Description: This program shows you how to copy a file byte by byte.
'             It reads 4 kbs from the source file and write them in
'             the destination file until it reads all byte in the source
'             file. There a bar that shows the copying progress.
'*************************************************************************
Private Sub CmdBrowse_Click()
'Set filter to all files
CmnDlg.Filter = "All files|*.*"
'Show the open file window
CmnDlg.ShowOpen
'Put the file bath in the source text
TxtSrc.Text = CmnDlg.FileName
End Sub
Private Sub CmdCopy_Click()
On Error GoTo CopyErr
'Declare variables
Dim SrcFile As String
Dim DestFile As String
Dim SrcFileLen As Long
Dim nSF, nDF As Integer
Dim Chunk As String
Dim BytesToGet As Integer
Dim BytesCopied As Long
'Disable the copy button
CmdCopy.Enabled = False
'The source file the you want to copy
SrcFile = TxtSrc
'The destination file name
DestFile = TxtDest
'Get source file length
SrcFileLen = FileLen(SrcFile)
'Progress bar settings
ProgressBar1.Min = 0
ProgressBar1.Max = SrcFileLen
'Open both files
nSF = 1
nDF = 2
Open SrcFile For Binary As nSF
Open DestFile For Binary As nDF
'How many bytes to get each time
BytesToGet = 4096 '4kb
BytesCopied = 0
'Show Progress
ProgressBar1.Value = 0
'Show percentage
LblPercent.Caption = "0"
'ProgressBar1.Visible = True
'Keep copying until finishing all bytes
Do While BytesCopied < SrcFileLen
    'Check how many bytes left
    If BytesToGet < (SrcFileLen - BytesCopied) Then
        'Copy 4 KBytes
        Chunk = Space(BytesToGet)
        Get #nSF, , Chunk
    Else
        'Copy the rest
        Chunk = Space(SrcFileLen - BytesCopied)
        Get #nSF, , Chunk
    End If
    BytesCopied = BytesCopied + Len(Chunk)
   
    'Show progress
    ProgressBar1.Value = BytesCopied
    'Show Percentage
    LblPercent.Caption = Int(BytesCopied / SrcFileLen * 100)
    LblPercent.Refresh
       
    'Put data in destination file
    Put #nDF, , Chunk
Loop
'Hide progress bar
ProgressBar1.Value = 0
'ProgressBar1.Visible = False
'Skip the error message and exit sub
GoTo Ex
CopyErr:
MsgBox Err.Description, vbCritical, "Error"
Ex:
'Close files
Close #nSF
Close #nDF
'Re-enable the copy button
CmdCopy.Enabled = True
End Sub
 
     
Edson
SÃO PAULO
SP - BRASIL
Postada em 12/08/2004 09:58 hs            
Bom dia....
     
Tekki
Pontos: 2843 Pontos: 2843 Pontos: 2843
UBERLÂNDIA
MG - BRASIL
Postada em 12/08/2004 12:06 hs            
'Tente este código
'Crie um projeto adicione dois texts com o nome txtFrom e txtTo e um CommandButton com o nome cmdCopy




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

Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Private Const FO_COPY = &H2
Private Const FOF_ALLOWUNDO = &H40
Public Sub SHCopyFile(ByVal from_file As String, ByVal to_file As String)
Dim sh_op As SHFILEOPSTRUCT

    With sh_op
        .hWnd = 0
        .wFunc = FO_COPY
        .pFrom = from_file & vbNullChar & vbNullChar
        .pTo = to_file & vbNullChar & vbNullChar
        .fFlags = FOF_ALLOWUNDO
    End With

    SHFileOperation sh_op
End Sub

Private Sub cmdCopy_Click()
    SHCopyFile txtFrom.Text, txtTo.Text
End Sub

Private Sub Form_Load()
Dim file_path As String

    file_path = App.Path
    If Right$(file_path, 1) <> "" Then file_path = file_path & ""

    txtFrom.Text = file_path & "TestFrom.txt"
    txtTo.Text = file_path & "TestTo.txt"
End Sub

     
Edson
não registrado
Postada em 12/08/2004 12:47 hs   
muito obrigada Tekki 
eu tenho este projeto só que ele usa o copy do windows
"copia arquivo com a animacao".
eu queria usa "ProgressBar1" eu tenho um outro projeto de outro site"......"
colocar na "Troca de arquivos"
     
Edson
SÃO PAULO
SP - BRASIL
Postada em 12/08/2004 13:05 hs            
eu sei que é pidir muito, e que não sei mesmo
     
Página(s): 1/1    


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

[:)] = 
[:P] = 
[:(] = 
[;)] = 

HTML DESLIGADO

     
 VOLTAR

  



CyberWEB Network Ltda.    © Copyright 2000-2026   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página