 |
 |

09-28-2002, 05:30 AM
|
|
|
How can i check if a file exists
|
I have to check if a file exist, caus when it don''t excists i have to un an other file, so what will be the code to check if a file excists
|
|

09-28-2002, 05:51 AM
|
|
Centurion
|
|
Join Date: Sep 2002
Location: Chandigarh
Posts: 143
|
|
__________________
Holla! If ya hear me!
|

09-28-2002, 05:56 AM
|
|
|
|
I can''t install MSDN, so i have no help function, so can u please tell me how to do it
|
|

09-28-2002, 07:21 AM
|
 |
MetaCenturion
Retired Moderator * Guru *
|
|
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
|
|
The Dir$ function returns the filename given in the first parameter if it exists, otherwise it returns "".
So you can check like this:
Code:
Dim TestStr As String
TestStr = Dir$("yourfilepath")
If Len(TestStr) = 0 Then
MsgBox "File Does not Exist."
End If
|
|

09-28-2002, 12:09 PM
|
 |
Lost Soul
Super Moderator * Guru *
|
|
Join Date: May 2001
Location: Vorlon
Posts: 18,884
|
|
|
Why can't you install MSDN??
You also can use MSDN online on the Microsoft website.
|
|

09-28-2002, 12:13 PM
|
|
Original Contributor
Retired Moderator * Guru *
|
|
Join Date: Jan 2001
Location: Watch Window
Posts: 2,781
|
|
You could also use ArnoutV's favorite way, the FileSystemObject has a FileExists method.
j/k ArnoutV 
|
__________________
JDT
|

09-28-2002, 01:05 PM
|
|
Newcomer
|
|
Join Date: Sep 2002
Posts: 23
|
|
|
you can use the filesystem obgect:
Public Function FileFind(FileLocation As String) As Boolean
Dim fso As FileSystemObject
Set fso = New FileSystemObject
If fso.FileExists(FileLocation) Then
FileFind = True
Else
FileFind = False
End If
End Function
the FileLocation string shuld be the full path to the file like:
c:\my documents\file1.txt
|
|

09-28-2002, 01:24 PM
|
 |
Obsessive OPtimizer
Administrator * Guru *
|
|
Join Date: Jun 2002
Location: Debug Window
Posts: 13,685
|
|
__________________
Quis custodiet ipsos custodues.
|

09-28-2002, 02:58 PM
|
|
|
|
Euhmm, i can''t MSDN because when it says locate the msdn disc, i put in the msdn disc, and it says it is the wrong disc. But anyway, u guys helped me out very much, it is working now
|
|

09-29-2002, 01:29 AM
|
 |
Centurion
|
|
Join Date: Sep 2002
Location: Bangladesh
Posts: 118
|
|
|
MSDN has a buh in it as I think - If you want to reinstall it it shows the message "Error creating collection and does not work. I see it in all of my friends. They guess it as a bug.
|
__________________
Hasin Hayder
http://www.vbsthopoti.cjb.net
Lead Programmer - EvelinDev
Things that are tough takes time - Things that are impossible takes a little more.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|