Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Copy File From One Location To Another + Urgent + Sourabh Das

Copy File From One Location To Another + Urgent + Sourabh Das

Scheduled Pinned Locked Moved Visual Basic
help
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dot Net Jantu
    wrote on last edited by
    #1

    Hi All, After A long time.. Hope u all are good.. I am having btnUpload and btnTransfer. On btnUpload I open a openFileDialogue select any type of file and at transfer i want to transfer it to another location suppose D:\TransferTest\. But its giving this error Could not find a part of the path 'D:\TransferTest\'. The code is as below :

    Dim filename As String
    Dim ofd As OpenFileDialog

    Private Sub btnUpload\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        ofd = New OpenFileDialog()
        ofd.Filter = "All Files|\*.\*"
        ofd.ShowDialog()
        If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
            filename = ofd.FileName()
            txtFile.Text = filename
        End If
    End Sub
    
    Private Sub btnTransfer\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click
        File.Copy(filename, "D:\\TransferTest\\")
    End Sub
    

    Help with a code tip... its a urgent.. Regards, Sourabh

    Thanks and Regards,

    K L P 3 Replies Last reply
    0
    • D Dot Net Jantu

      Hi All, After A long time.. Hope u all are good.. I am having btnUpload and btnTransfer. On btnUpload I open a openFileDialogue select any type of file and at transfer i want to transfer it to another location suppose D:\TransferTest\. But its giving this error Could not find a part of the path 'D:\TransferTest\'. The code is as below :

      Dim filename As String
      Dim ofd As OpenFileDialog

      Private Sub btnUpload\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
          ofd = New OpenFileDialog()
          ofd.Filter = "All Files|\*.\*"
          ofd.ShowDialog()
          If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
              filename = ofd.FileName()
              txtFile.Text = filename
          End If
      End Sub
      
      Private Sub btnTransfer\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click
          File.Copy(filename, "D:\\TransferTest\\")
      End Sub
      

      Help with a code tip... its a urgent.. Regards, Sourabh

      Thanks and Regards,

      K Offline
      K Offline
      kriskomar
      wrote on last edited by
      #2

      Try using the new filesystem namespace: FileSystem.FileCopy(filename, "D:\TransferTest\")

      1 Reply Last reply
      0
      • D Dot Net Jantu

        Hi All, After A long time.. Hope u all are good.. I am having btnUpload and btnTransfer. On btnUpload I open a openFileDialogue select any type of file and at transfer i want to transfer it to another location suppose D:\TransferTest\. But its giving this error Could not find a part of the path 'D:\TransferTest\'. The code is as below :

        Dim filename As String
        Dim ofd As OpenFileDialog

        Private Sub btnUpload\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
            ofd = New OpenFileDialog()
            ofd.Filter = "All Files|\*.\*"
            ofd.ShowDialog()
            If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
                filename = ofd.FileName()
                txtFile.Text = filename
            End If
        End Sub
        
        Private Sub btnTransfer\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click
            File.Copy(filename, "D:\\TransferTest\\")
        End Sub
        

        Help with a code tip... its a urgent.. Regards, Sourabh

        Thanks and Regards,

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, in Windows you can only create/move/copy files to existing folders, so if either D:\ or D:\TransferTest\ does not exist, you would get such error. You should use Directory.CreateDirectory() to create a folder (no need to test for existence first!). :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


        1 Reply Last reply
        0
        • D Dot Net Jantu

          Hi All, After A long time.. Hope u all are good.. I am having btnUpload and btnTransfer. On btnUpload I open a openFileDialogue select any type of file and at transfer i want to transfer it to another location suppose D:\TransferTest\. But its giving this error Could not find a part of the path 'D:\TransferTest\'. The code is as below :

          Dim filename As String
          Dim ofd As OpenFileDialog

          Private Sub btnUpload\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
              ofd = New OpenFileDialog()
              ofd.Filter = "All Files|\*.\*"
              ofd.ShowDialog()
              If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
                  filename = ofd.FileName()
                  txtFile.Text = filename
              End If
          End Sub
          
          Private Sub btnTransfer\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click
              File.Copy(filename, "D:\\TransferTest\\")
          End Sub
          

          Help with a code tip... its a urgent.. Regards, Sourabh

          Thanks and Regards,

          P Offline
          P Offline
          PoweredByOtgc
          wrote on last edited by
          #4

          Private Sub btnTransfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click if not io.directory.exists("D:\TransferTest\") then io.directory.createdirectory("D:\Tran.....") enf if File.Copy(filename, "D:\TransferTest\") End Sub

          L 1 Reply Last reply
          0
          • P PoweredByOtgc

            Private Sub btnTransfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click if not io.directory.exists("D:\TransferTest\") then io.directory.createdirectory("D:\Tran.....") enf if File.Copy(filename, "D:\TransferTest\") End Sub

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            so far for "no need to test for existence"... :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups