About: How to check if a file exists   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

If you insert the following line before the spot where you intend to use the file, it will raise a ‘File not found’ error if the file doesn't exist: FileLen Substitute with a string constant or variable specifying the file name. If you prefer to use a more robust check that does not generate an error, just add this function to your project: Public Function FileExists(filename As String) As Boolean FileExists = Len(Dir(filename, vbNormal)) > 0 End Function Then call it as expected to check if a file exists: If FileExists("C: est.bas") Then End If

AttributesValues
rdfs:label
  • How to check if a file exists
rdfs:comment
  • If you insert the following line before the spot where you intend to use the file, it will raise a ‘File not found’ error if the file doesn't exist: FileLen Substitute with a string constant or variable specifying the file name. If you prefer to use a more robust check that does not generate an error, just add this function to your project: Public Function FileExists(filename As String) As Boolean FileExists = Len(Dir(filename, vbNormal)) > 0 End Function Then call it as expected to check if a file exists: If FileExists("C: est.bas") Then End If
dcterms:subject
abstract
  • If you insert the following line before the spot where you intend to use the file, it will raise a ‘File not found’ error if the file doesn't exist: FileLen Substitute with a string constant or variable specifying the file name. If you prefer to use a more robust check that does not generate an error, just add this function to your project: Public Function FileExists(filename As String) As Boolean FileExists = Len(Dir(filename, vbNormal)) > 0 End Function Then call it as expected to check if a file exists: If FileExists("C: est.bas") Then End If Alternatively, you can use the FileSystemObject to check for a file's existence: Public Function FileExists(filename As String) As Boolean Static fso As Object If fso Is Nothing Then Set fso = CreateObject("Scripting.FileSystemObject") FileExists = fso.FileExists(filename) End Function
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software