--- In helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com, "Joe Wasko" <jpw...> wrote:
>
> All,
> Please help me. I have an application that is reading Excel file
using
> OLE_DB. The problem is I need to ensure the file
> is sited in the directory before I can make a connection to it.
The files
> are coming from another PC and are going to a shared folder on
> the system that will be establishing the connection.
>
> How can I be sure the process of copying is complete?
>
> "HOT ISSUE"
>
> PLEASE HELP
>
> Joseph Wasko
>
> Pannier Corporation
>
> Software Engineer
>
> P: 412-492-1400 X 314
>
> F: 412-492-1418
>
> <mailto:jpw...> jpw...
>
> <http://www.pannier.com/> www.pannier.com
>
Joseph:
I wrote this piece of code serveral years ago, but it should work
with minor changes:
'----------------------------------------------------------
----------
Public Function FileExists(theFile As String) As Boolean ' Date: 5/14/01 ' Author: Milton Rojas
' Purpose: Checks to see if the file name passed exists. Returns
True if file exists
' Called by: EmailFiles, EmailTemplates
' Calls: LogErrors
' Last Update:5/14/01
Dim X As String
On Error GoTo ExistsError
X = Dir(theFile)
If X <> "" Then
FileExists = True
Else
FileExists = False
End If
Exit Function
ExistsError:
gblnSevere = True
gblnThereWasAnError = True
FileExists = True
LogErrors ("modFileUtils.FileExists: " & Err.Description)
End Function
Milton
Milton your function will tell you if the file is there but not if it is
zero bytes, so if you try and open the file for input it will error out on you.
Maybe try this
Public Function FileExists(sSource As String) As Boolean
Free = FreeFile
Open sSource For Binary As #Free
If LOF(Free) <> 0 Then
FileExists = True
Close #Free
Else
Close #Free
FileExists = False
Kill sSource End If
End Function
At 09:27 PM 3/3/2008, you wrote:
>--- In helpwithvb%40yahoogroups.com">helpwithvbyahoogroups.com, "Joe Wasko" <jpw...> wrote:
> >
> > All,
> > Please help me. I have an application that is reading Excel file
>using
> > OLE_DB. The problem is I need to ensure the file
> > is sited in the directory before I can make a connection to it.
>The files
> > are coming from another PC and are going to a shared folder on
> > the system that will be establishing the connection.
> >
> > How can I be sure the process of copying is complete?
> >
> > "HOT ISSUE"
> >
> > PLEASE HELP
> >
> > Joseph Wasko
> >
> > Pannier Corporation
> >
> > Software Engineer
> >
> > P: 412-492-1400 X 314
> >
> > F: 412-492-1418
> >
> > <mailto:jpw...> jpw...
> >
> > <http://www.pannier.com/> www.pannier.com
> >
>
>Joseph:
>
>I wrote this piece of code serveral years ago, but it should work
>with minor changes:
>
>'----------------------------------------------------------
>----------
>Public Function FileExists(theFile As String) As Boolean >' Date: 5/14/01 >' Author: Milton Rojas
>' Purpose: Checks to see if the file name passed exists. Returns >True if file exists
>' Called by: EmailFiles, EmailTemplates
>' Calls: LogErrors
>' Last Update:5/14/01
>
> Dim X As String
> On Error GoTo ExistsError
> X = Dir(theFile)
> If X <> "" Then
> FileExists = True
> Else
> FileExists = False
> End If
> Exit Function
>ExistsError:
> gblnSevere = True
> gblnThereWasAnError = True
> FileExists = True
> LogErrors ("modFileUtils.FileExists: " & Err.Description)
>End Function
>
>Milton
>
>
>
>
>
>Yahoo! Groups Links
>
>
>