bakershawnm
Programmer
I have a program that I am trying to convert to a service (using VS 2008). The program uses DirectoryInfo to search for files in a specified folder. I use absolute path names as I can never be confident that I will have a drive mapped. The path names do have spaces in them and the ultimate subpath is date specific (i.e 7-26-10). In that date folder will be numerous files and I need to weed through them to find the ones I need and import their data into a SQL server.
So my path looks like this \\Theta2\Public1\Polaris\CAWG\Widgets Received Data\Received Drops\7-26-10
Everything works just great if the program is run interactively and the user selects the path to import from.
I have done all the threading and built the service and everything in the service seems to be working fine except where the initial search of the folder is concerned. It seems that (when running in a service) the folder does not exist.
This is my proof code that tells me it does not recognize the folder. It is the exact same code in the interactive program as in the service.
Dim configfl As String = "C:\ServicesTesting\BCADataService.ini"
Dim srcfldr As String
If File.Exists(configfl) Then
Dim strmrdr As New StreamReader(configfl)
srcfldr = strmrdr.ReadLine
srcfldr = Mid(srcfldr, InStr(srcfldr, "=") + 2)
strmrdr.Close()
Dim rootfldr As DirectoryInfo = New DirectoryInfo(srcfldr)
If rootfldr.Exists Then
evntlog.WriteEntry(srcfldr & " exists.")
End If
End If
and then in a subfunction this:
Dim fldrinfo As DirectoryInfo = New DirectoryInfo(srcfldr)
evntlog.WriteEntry(fldrinfo.FullName)
If (fldrinfo.Exists = True) Then
evntlog.WriteEntry("folder exists")
.
.
.
Else
evntlog.WriteEntry("Source folder " & fldrinfo.FullName & " does not exist")
End If
I do not get the first entry in the event log at the rootfldr. I do get the last event log entry that says it does not exist.
So my question is this:
Do the spaces and/or dashes in the path name provide different results when running as a service?
If so, recommendations other than renaming the path (I will do that if there are no other options) would be welcome.
If not then is it possible that I am doing something wrong somewhere in the initial installation and registration of my service?
So my path looks like this \\Theta2\Public1\Polaris\CAWG\Widgets Received Data\Received Drops\7-26-10
Everything works just great if the program is run interactively and the user selects the path to import from.
I have done all the threading and built the service and everything in the service seems to be working fine except where the initial search of the folder is concerned. It seems that (when running in a service) the folder does not exist.
This is my proof code that tells me it does not recognize the folder. It is the exact same code in the interactive program as in the service.
Dim configfl As String = "C:\ServicesTesting\BCADataService.ini"
Dim srcfldr As String
If File.Exists(configfl) Then
Dim strmrdr As New StreamReader(configfl)
srcfldr = strmrdr.ReadLine
srcfldr = Mid(srcfldr, InStr(srcfldr, "=") + 2)
strmrdr.Close()
Dim rootfldr As DirectoryInfo = New DirectoryInfo(srcfldr)
If rootfldr.Exists Then
evntlog.WriteEntry(srcfldr & " exists.")
End If
End If
and then in a subfunction this:
Dim fldrinfo As DirectoryInfo = New DirectoryInfo(srcfldr)
evntlog.WriteEntry(fldrinfo.FullName)
If (fldrinfo.Exists = True) Then
evntlog.WriteEntry("folder exists")
.
.
.
Else
evntlog.WriteEntry("Source folder " & fldrinfo.FullName & " does not exist")
End If
I do not get the first entry in the event log at the rootfldr. I do get the last event log entry that says it does not exist.
So my question is this:
Do the spaces and/or dashes in the path name provide different results when running as a service?
If so, recommendations other than renaming the path (I will do that if there are no other options) would be welcome.
If not then is it possible that I am doing something wrong somewhere in the initial installation and registration of my service?