Copy files without overwrite 
Author Message
 Copy files without overwrite

Hello!  I'm quite new to VB5 and I'm trying to copy files from one drive (a
local hard drive) to another drive (a mapped network drive) without
overwriting any files that exist on the dest. drive.  For example.. Let's
say I have e: mapped to the drive I want to be the dest. drive.  It would
copy from c:\ to e:\ including all subdirs, but it would not overwrite any
files that already existed on e:\.  I hope I explained this well..  Any
help would be appreciated!  I have a friend who claims he is very
knowledgeable with VB5, but doesn't know how I should go about it.  Thanks
in advance!!!


Tue, 02 Jan 2001 03:00:00 GMT  
 Copy files without overwrite
One way is to check for filesizes in the destination folder/drive, there are
other possibilities as well but I would think this one is the most flexible.
Create a function like this:

Public Function CheckStatus(FileName as String)
    On Error Resume Next
    CheckStatus = FileLen(FileName)
    If Err Then CheckStatus = -1
End Function

In your code you could type:

If CheckStatus(TheFileIMightWantToSend) > -1 then
     ... filecopy bla bla bla...
Else
    ... check the next file I might want to send bla bla bla...
End if

Note that files can be 0 bytes of size - Windows does not register the size
of them until the whole file is there.  That's why you should check for 0
bytes as well, and that's what I think makes this function what you are
looking for.

It sounds as if you are writing a backup program of some sort, if so you
should study the GetAttr and SetAttr functions if you don't want to back up
files that have been backed up recently.  These are simple functions and
well descibed in the VB help files.

Best of luck,

Jn skar Magnsson


Quote:
>Hello!  I'm quite new to VB5 and I'm trying to copy files from one drive (a
>local hard drive) to another drive (a mapped network drive) without
>overwriting any files that exist on the dest. drive.  For example.. Let's
>say I have e: mapped to the drive I want to be the dest. drive.  It would
>copy from c:\ to e:\ including all subdirs, but it would not overwrite any
>files that already existed on e:\.  I hope I explained this well..  Any
>help would be appreciated!  I have a friend who claims he is very
>knowledgeable with VB5, but doesn't know how I should go about it.  Thanks
>in advance!!!



Tue, 02 Jan 2001 03:00:00 GMT  
 Copy files without overwrite
Thanks for your help!  Actually, what I want to do is create a program for
transferring files from one PC to another over a network but without
overwriting files.  A friend of mine and I  have thought about just writing
a script that automatically hits the "No" on the "Confirm File Overwrite"
window, but I thought there would be an easier way of telling VB to copy
every file in every directory except what already exists on the new machine.
Therefore it will not overwrite any system files, program files, etc.  We
reinstall all the software before we do the file transfer, so the
applications are already registered, but this way we can be sure to get all
the data, cfg settings, old dos apps that don't have to be reinstalled, just
copied, etc...  Just trying to make my job a little easier! :)



Quote:
>One way is to check for filesizes in the destination folder/drive, there
are
>other possibilities as well but I would think this one is the most

flexible.


Wed, 03 Jan 2001 03:00:00 GMT  
 Copy files without overwrite
Syntax

Dir[(pathname[, attributes])]

The Dir function syntax has these parts:

Part    Description

pathname        String expression that specifies a filenamemay include directory
or folder, and drive.  Null is returned if pathname is not found.
attributes      Constant or numeric expression, the sum of which specifies file
attributes.  If omitted, all normal files are returned that match pathname.

' In Microsoft Windows:
' Returns "WIN.INI" if it exists.
MyFile = Dir("C:\WINDOWS\WIN.INI")    

If the file does not exist, a zero length string is returned.  That can be
used to determine if the file is already in a particular directory (If you
know the path).

If Dir(MyFileandPath) = "" then
        FileCopy MyFileSource MyFileandPath
End If




Quote:
> Thanks for your help!  Actually, what I want to do is create a program
for
> transferring files from one PC to another over a network but without
> overwriting files



> >One way is to check for filesizes in the destination folder/drive, there
> are
> >other possibilities as well but I would think this one is the most
> flexible.



Wed, 03 Jan 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. writing to file without overwriting text already there?

2. Copying .mdb files to floppy -- overwriting the old ones

3. overwrite newer files only in copy

4. newbie: copy a file and overwrite with vbscript?

5. Word 2000 VBA - SaveAs Method Overwrites Without Warning

6. copy file without FSO

7. Find a copy a file with File.Copy method

8. overwrite file?

9. overwrite file??

10. overwrite file??

11. Overwriting a file

12. File Overwrite Problems <-- VIRUS ATTACHED!

 

 
Powered by phpBB® Forum Software