Results 1 to 3 of 3

Thread: [RESOLVED] Moving of file using command Button

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2010
    Posts
    51

    Resolved [RESOLVED] Moving of file using command Button

    i am trying to moving a file using this Code

    1 Code:
    1. 'Dim strFileName As String
    2.    
    3.     'upload file link into database
    4.     'cdlUpload.DialogTitle = "Upload File"
    5.     'cdlUpload.Filter = "All Files(*.*)|*.*|Office Document 1997-2000(*.doc)|*.doc|Office Document 2003-2010(*.docx)|*.docx|"
    6.     'cdlUpload.Flags = cdlOFNFileMustExist + cdlOFNPathMustExist
    7.     'On Error GoTo ERR_Handler
    8.     'cdlUpload.ShowOpen
    9.    
    10.     'strFileName = cdlUpload.FileName
    11.    
    12.        
    13.     'FileSystem.FileCopy(strFileName, "C:\Documents and Settings\Fadairo Fussy Fisayo\Desktop\my very new project\Server") = = (strFileName)
    14.    
    15. 'ERR_Handler:
    16.  '   Exit Sub

    but i dont know why its not working..
    please i need assistance..

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Moving of file using command Button

    Your FileSystem.FileCopy syntax has some issues. To find what it is compare what you have vs this sample code:
    Code:
    Private Sub Command1_Click()
    Dim strSourceFileName As String
    Dim strDestination As String
    
    On Error GoTo ERR_Handler
    
        'upload file link into database
        cdlUpload.DialogTitle = "Upload File"
        cdlUpload.Filter = "All Files(*.*)|*.*|Office Document 1997-2000(*.doc)|*.doc|Office Document 2003-2010(*.docx)|*.docx|"
        cdlUpload.Flags = cdlOFNFileMustExist + cdlOFNPathMustExist
        cdlUpload.ShowOpen
        
        strSourceFileName = cdlUpload.FileName
        strDestination = "C:\test\" & Mid(strSourceFileName, InStrRev(strSourceFileName, "\") + 1)
        
        If Not Dir(strDestination) = "" Then
            If MsgBox("Destination file alreay exists. Would like to override existing?", vbYesNo + vbDefaultButton2, "Confirm File Copy") = vbNo Then
                Exit Sub
            End If
        End If
        
        FileSystem.FileCopy strSourceFileName, strDestination
        
        Exit Sub
    
    ERR_Handler:
    
        MsgBox "An error has occured while copying file. Operation aborted.", vbExclamation, "File Copy Error"
        Err.Clear
    
    End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2010
    Posts
    51

    Re: Moving of file using command Button

    [QUOTE=RhinoBull;3879722]Your FileSystem.FileCopy syntax has some issues. To find what it is compare what you have vs this sample code:
    [code]
    Private Sub Command1_Click()
    Dim strSourceFileName As String
    Dim strDestination As String

    On Error GoTo ERR_Handler

    'upload file link into database
    cdlUpload.DialogTitle = "Upload File"
    cdlUpload.Filter = "All Files(*.*)|*.*|Office Document 1997-2000(*.doc)|*.doc|Office Document 2003-2010(*.docx)|*.docx|"
    cdlUpload.Flags = cdlOFNFileMustExist + cdlOFNPathMustExist
    cdlUpload.ShowOpen

    strSourceFileName = cdlUpload.FileName
    strDestination = "C:\test\" & Mid(strSourceFileName, InStrRev(strSourceFileName, "\") + 1)

    If Not Dir(strDestination) = "" Then
    If MsgBox("Destination file alreay exists. Would like to override existing?", vbYesNo + vbDefaultButton2, "Confirm File Copy") = vbNo Then
    Exit Sub
    End If
    End If

    FileSystem.FileCopy strSourceFileName, strDestination

    Exit Sub

    ERR_Handler:

    MsgBox "An error has occured while copying file. Operation aborted.", vbExclamation, "File Copy Error"
    Err.Clear

    End Sub

    Thanks man so if i use this code
    2 Code:
    1. strSourceFileName = cdlUpload.FileName
    2.     strDestination = "C:\test\" & Mid(strSourceFileName, InStrRev(strSourceFileName, "\") + 1)
    it will send the File to the location?? wat about if i want just the File name of the Copied file to show on another form and i will be able to redirect (like download) given file into the desktop of my come???

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width