|
-
Mar 4th, 2002, 04:52 AM
#1
Thread Starter
Addicted Member
Determine if file exists
Hello,
I would like to have a function or so can check if a given file exists.
Can anyone help please.......
Thanks
vbBoy.
-
Mar 4th, 2002, 04:56 AM
#2
Lively Member
Hi,
You can use this code
Code:
Public Function FileExists(Bestand As String) As Boolean
FileExists = (Dir(Bestand) <> "")
End Function
Public Function Run_Update_Quotations()
strSource = "\\Euermw01\Access\SalesDB\Data\Quotations_Data.mdb"
strDestination = "\\Euermw01\Access\SalesDB\Data\Quotations_Backup_" & _
Day(Now()) & "_" & Month(Now()) & "_" & Year(Now()) & ".mdb"
If Not FileExists(strDestination) Then
FileCopy strSource, strDestination
End If
...
End Function
If you can solve the problem, why worrying about it…
If you can’t solve the problem, worrying won’t help…
De la Motte Günther
-
Mar 4th, 2002, 04:56 AM
#3
Retired VBF Adm1nistrator
VB Code:
'' Does a given file exist ?
Private Function Exists(ByVal strFullPath As String) As Boolean
Exists = Len(Dir(strFullPath)) <> 0
End Function
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Mar 4th, 2002, 04:57 AM
#4
Bouncy Member
use the Dir() funciton.
usage Dir("filepath")
example:
VB Code:
If Dir("C:\bob.txt") Then 'File exists
'you code here
End if
-
Mar 4th, 2002, 05:19 AM
#5
Originally posted by darre1
use the Dir() funciton.
usage Dir("filepath")
example:
VB Code:
If Dir("C:\bob.txt") Then 'File exists
'you code here
End if
Sorry to say this but your code doesn't work.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Mar 4th, 2002, 05:21 AM
#6
Retired VBF Adm1nistrator
teeheehee
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Mar 4th, 2002, 05:26 AM
#7
Bouncy Member
you're quite right.
should be:
VB Code:
If Dir("C:\bob.txt") <> "" Then 'File exists
'you code here
End if
-
Mar 4th, 2002, 05:27 AM
#8
Bouncy Member
Originally posted by plenderj
teeheehee
bollocks
-
Mar 4th, 2002, 05:28 AM
#9
Retired VBF Adm1nistrator
Thats the normal way of doing it, but my approach is actually faster as far as I know.
Comparing numbers is faster than strings you see
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Mar 4th, 2002, 05:50 AM
#10
Bouncy Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|