• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 129
  • Last Modified:

file find question

i want to check the existance of a file in my path (which is set thru my autoexec.bat)

any quick way?
0
ackid32
Asked:
ackid32
1 Solution
 
rdrunnerCommented:
is it one ore more paths you can set there?

one path is easy

Dim ofso As New FileSystemObject
Debug.Print ofso.FileExists(Environ("mypath") & "\myFile.txt")

for more then one path you would need to split them into an array and check for each element
0
 
XpGauthamCommented:
if len(dir("c:\File.txt",vbNormal) <> 0 then
  msgbox "File Found !!!",vbinformation
else
  msgbox "File Not Found !!!",vbCritical
end if

if it is a system file use vbSystem instead of vbnormal
0
 
Naveen SwamyYash Infinite Solutions Private LimitedCommented:
if dir("c:\File.txt",6) = "" then
    msgbox "File not found"
end if
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ackid32Author Commented:
i may have paths like c:\windows\;c:\windows\system;c:\windows\command;d:\utils
not only like this but also vary
0
 
rdrunnerCommented:
For a full path list you need this

Dim ofso As New FileSystemObject
dim aPath as string
dim i as integer
apath=split(Environ("mypath"),";")
for i = 0 to ubound(apath)
  if ofso.FileExists(apath(i) & "\myFile.txt") then exit for
next
if i <= ubound(apath) then msgbox " the file exits at : " & apath(i)
0
 
ackid32Author Commented:
any other simple way?
0
 
rdrunnerCommented:
thats the simple one ;)
0
 
CleanupPingCommented:
ackid32:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
DanRollinsCommented:
Moderator, my recommended disposition is:

    Accept rdrunner's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now