Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2003, 05:37 PM
Registered User
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to overwrite local files?

Hi,

I have 2 files - 1 on the network and the other on my local drive.
They have the same name. I want to be able to compare their creation/change dates and if the network one is newer than the local one I want to be able to overwrite the local one with the file from the network. Here is what I have so far, but it doesn't seem to work
on XP:
My form has 1 OLE2 control.

Private Sub Form_Load()
Dim sysdrive

   Dim v As Variant
   v = "SYSTEMDRIVE"
   sysdrive = Environ(CStr(v))

If DateDiff("h", FileDateTime(sysdrive & "c:\myfile.txt"), FileDateTime("\\somenetworkpath\myfile.txt")) > 0 Then OLE2.DoVerb
End
End Sub



 
Old August 15th, 2003, 07:57 PM
Registered User
 
Join Date: Aug 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Presumably the environment variable SYSTEMDRIVE will return a drive string.

If so, the string 'sysdrive & "c:\myfile.txt"' will include two drive designators, making the FileDateTime function fail to give a valid value (probably thinks the file does not exist).

 
Old August 17th, 2003, 05:55 PM
Registered User
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Patanjali
 Presumably the environment variable SYSTEMDRIVE will return a drive string.

If so, the string 'sysdrive & "c:\myfile.txt"' will include two drive designators, making the FileDateTime function fail to give a valid value (probably thinks the file does not exist).

No I made a type while posting my code - in my program I don't have "c:\myfile.txt", just "myfile.txt". And like I said it works fine on my Win 2000 machine but fails on any XP machine.
 
Old August 18th, 2003, 04:02 AM
Registered User
 
Join Date: Aug 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It does work on an XP Pro machine!

Though, this was with 'sysdrive & "\myfile.txt"' as the parameter.

PS. You did not previously mention that it worked on 2000.Perhaps the SYSTEMDRIVE environment variable is 'C:' for XP and 'C:\' for 2000?


 
Old August 18th, 2003, 08:06 PM
Registered User
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Patanjali
 It does work on an XP Pro machine!

Though, this was with 'sysdrive & "\myfile.txt"' as the parameter.

PS. You did not previously mention that it worked on 2000.Perhaps the SYSTEMDRIVE environment variable is 'C:' for XP and 'C:\' for 2000?







Similar Threads
Thread Thread Starter Forum Replies Last Post
help...copy files from sharepoint to local folder pinkflakes .NET Web Services 0 November 3rd, 2007 10:02 PM
Copy Files and Folders on Local Network rupakroy5 VB.NET 2002/2003 Basics 1 May 22nd, 2006 10:09 AM
How to open downloaded files from local machine kumarop Pro JSP 0 April 1st, 2006 08:52 AM
Retrieve data from local Access files aslyon ADO.NET 2 October 31st, 2003 08:52 PM
Dealing with local files Ray Pinnegar Beginning PHP 4 July 24th, 2003 03:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.