Solved

How to find if a File Exists?

Posted on 2004-08-15
4
143 Views
Last Modified: 2010-05-02
Very Simple.  I want to know if a particular file (temp.txt) exists before I try to kill it.  Sometimes it's there and sometimes it's not.  if it's not Kill \temp.txt fails.

I read in my book about the function FileExists(\temp) but my version of VB does not have it available.  Is there another way to do it?

0
Comment
Question by:mlcktmguy
  • 3
4 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 11807280
Private Sub Command1_Click()
    Dim fileName As String
   
    fileName = "c:\temp.txt"
    If Dir(fileName) <> "" Then
        Kill fileName
    End If
End Sub
0
 
LVL 34

Expert Comment

by:flavo
ID: 11807289
myFile = "c:\myFile.txt"

If len(dir(myFile) then
  kill myFile
end if
0
 
LVL 34

Expert Comment

by:flavo
ID: 11807292
hmm.. should have refreshed, got distracted.

Dave
0
 
LVL 34

Expert Comment

by:flavo
ID: 11807294
>> If len(dir(myFile) then

If len(dir(myFile)) then
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now