none
Copying files to Portable Device RRS feed

  • Question

  • I want Copying files to  Portable Device

    Use the following code to copy the file to the regular folder

    System.IO.File.Copy("C:\Source\somefile.txt", "C:\Destination\somefile.txt")

    Thursday, November 16, 2017 7:14 PM

All replies

  • I want Copying files to  Portable Device

    Use the following code to copy the file to the regular folder

    System.IO.File.Copy("C:\Source\somefile.txt", "C:\Destination\somefile.txt")

     The code you showed will copy a file so,  what specific problem are you having?  Are you having problem finding a specific portable drive that you want to copy it to?  Are you having a problem constructing a path and filename for the destination?  Maybe a problem getting the filenames to copy from a folder?

     We can't really give an answer or example if we don't know whet problem you are having with the File.Copy method.


    If you say it can`t be done then i`ll try it

    Thursday, November 16, 2017 8:32 PM
  • I want Copying files to  Portable Device

    ahmed,

    Is this of any help?

    https://msdn.microsoft.com/en-us/library/windows/desktop/dd388998(v=vs.85).aspx


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Thursday, November 16, 2017 10:56 PM
  • having problem finding a specific portable drive that i want to copy it to? 

    Thursday, November 16, 2017 10:56 PM
  • having problem finding a specific portable drive that i want to copy it to? 

    This lists the drives and types.

    Imports System.IO
    
    Public Class Form5
        Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            Dim drv As DriveInfo
    
            For Each drv In DriveInfo.GetDrives
    
                If drv.DriveType <> DriveType.Removable Then
    
                    ListBox1.Items.Add(drv.Name & "  " & drv.DriveType.ToString)
    
                End If
            Next
        End Sub
    End Class


    Thursday, November 16, 2017 11:31 PM
  • having problem finding a specific portable drive that i want to copy it to? 

    Do you mean that you need to find the drive letter that the Operating System has assigned to a particular removable drive when that drive is connected?

    You need to determine what are you going to use to identify the drive.   Once you know that you can get information for all drives and see which one matches your criteria.  See:
    https://msdn.microsoft.com/en-us/library/system.io.driveinfo.getdrives(v=vs.110).aspx

    Thursday, November 16, 2017 11:32 PM
  • having problem finding a specific portable drive that i want to copy it to? 

    I think we're having a time with the terminology here:

    Do you mean a removable drive? That's not the same as portable.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Thursday, November 16, 2017 11:34 PM
  • having problem finding a specific portable drive that i want to copy it to? 

    If you're talking about removable drives, the following will give you a string array of all removable drives which are "ready" and which are removable, as drive letters, sorted alphabetically:

    Dim removableDrives() As String = _
                (From drv As IO.DriveInfo In IO.DriveInfo.GetDrives _
                     Where drv.IsReady AndAlso _
                           drv.DriveType = IO.DriveType.Removable _
                               Select drv.Name _
                                  Order By Name).ToArray
    


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Thursday, November 16, 2017 11:48 PM
  • having problem finding a specific portable drive that i want to copy it to? 

    If you're talking about removable drives, the following will give you a string array of all removable drives which are "ready" and which are removable, as drive letters, sorted alphabetically:

    Dim removableDrives() As String = _
                (From drv As IO.DriveInfo In IO.DriveInfo.GetDrives _
                     Where drv.IsReady AndAlso _
                           drv.DriveType = IO.DriveType.Removable _
                               Select drv.Name _
                                  Order By Name).ToArray


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    removable is not  portable drive  

    mobile drive

    Thursday, November 16, 2017 11:57 PM

  • removable is not  portable drive  

    mobile drive

    So you do mean something like a Smart Phone then?

    That's a different animal entirely.

    Look through the various links of what I posted earlier. If nothing else, it'll be an experience. ;-)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, November 17, 2017 12:00 AM