flashdisk (1 Viewer)

sandy70

Registered User.
Local time
Yesterday, 20:29
Joined
Apr 16, 2008
Messages
36
hi...

is there anyone can help me with my flashdisk problem ??

usually i use this code to back up my client data to falsh disk
Source = "D:\Data\BUBU\Data\DataI.mdb"
Target = "g:\Data\DataI.mdb"
FileCopy Source, Target

the problem is sometime the flashdisk drive change from G to H or to I

is there any way that i can detect automaticlly flashdisk drive ??
 

VilaRestal

';drop database master;--
Local time
Today, 04:29
Joined
Jun 8, 2011
Messages
1,046
The only way I can think of is by the quite ugly method of putting a file on the drive with a peculiar name and then using fso to find if the file exists.

Something like:

Code:
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Dim i As Integer
    Dim GotIt As Boolean
    For i = 69 To 90 'Characters E to Z
        If fso.FileExists(Chr(i) & ":\pathtestfile") Then
            GotIt = True
            Exit For
        End If
    Next i
    If GotIt Then
        Source = "D:\Data\BUBU\Data\DataI.mdb"
        Target = Chr(i) & ":\Data\DataI.mdb"
        FileCopy Source, Target
    End If

It's best if paths like that aren't hard coded - look up a field in a settings table - so you don't need to modify code to change a path.
 

sandy70

Registered User.
Local time
Yesterday, 20:29
Joined
Apr 16, 2008
Messages
36
The only way I can think of is by the quite ugly method of putting a file on the drive with a peculiar name and then using fso to find if the file exists.

Something like:

Code:
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Dim i As Integer
    Dim GotIt As Boolean
    For i = 69 To 90 'Characters E to Z
        If fso.FileExists(Chr(i) & ":\pathtestfile") Then
            GotIt = True
            Exit For
        End If
    Next i
    If GotIt Then
        Source = "D:\Data\BUBU\Data\DataI.mdb"
        Target = Chr(i) & ":\Data\DataI.mdb"
        FileCopy Source, Target
    End If
It's best if paths like that aren't hard coded - look up a field in a settings table - so you don't need to modify code to change a path.

its works tq :D :D
 

Users who are viewing this thread

Top Bottom