Below is a routine I use for creating log files. It works great on most VB
Applications. However, for web services, it needs some help. The problem
is I cant reflect properly into a web service to find out where the .DLL is.
As is, this code writes a log file ok, but the log file ends up buried
directory deep inside the .Net Framework directories. Anyone know how to
find the path of a web service .DLL so I can fix this code to write to the
"bin" directory where the Web Service Dll is?
Public Function get_name_of_application(Optional ByVal
IncludeFullPathOfExe As Boolean = False) As String
Dim Application_Directory As String
Dim Asm As System.Reflection.Assembly = _
System.Reflection.Assembly.GetExecutingAssembly
Dim strConfigLoc As String = Asm.Location
If Not IncludeFullPathOfExe Then
strConfigLoc = GetFileNameOnly(Asm.Location)
End If
get_name_of_application = strConfigLoc.ToString
End Function
Public Sub COMMON_Module_Print(ByVal MyMessage As String, Optional ByVal
WriteToFile As Boolean = False)
Try
Static TodaysDate As Date = Now
Debug.WriteLine(MyMessage)
If WriteToFile Then
Dim OutputLogFileName As String =
get_name_of_application(True) & ".Log"
COMMON_FILE_Module.FILE_AppendFile(MyMessage,
OutputLogFileName)
If Now.Date < TodaysDate.Date Then
'Archive OutputFile
Dim ArchivedFileName As String = OutputLogFileName &
".Archived." & Now.Date.ToShortDateString.Replace("/", "-")
FILE_ForceMove(OutputLogFileName, ArchivedFileName)
TodaysDate = Now
End If
End If
Catch ex As Exception
RaiseEvent Mod_Print("COMMON_Module_Print: " & ex.Message)
End Try
End Sub