Hi, I took this code from this site
[url]http://www.codeproject.com/aspnet/createlogfiles.asp
Specifically in this part
public CreateLogFiles()
{
//sLogFormat used to create log files format :
// dd/mm/yyyy hh:mm:ss AM/PM ==> Log Message
sLogFormat = DateTime.Now.ToShortDateString().ToString()+” “+DateTime.Now.ToLongTimeString().ToString()+” ==> “;
//this variable used to create log filename format ”
//for example filename : ErrorLogYYYYMMDD
string sYear = DateTime.Now.Year.ToString();
string sMonth = DateTime.Now.Month.ToString();
string sDay = DateTime.Now.Day.ToString();
sErrorTime = sYear+sMonth+sDay;
}
in vb.net this is what I did:
Public Function CreateLogFiles()
‘sLogFormat used to create log files format :
‘ dd/mm/yyyy hh:mm:ss AM/PM ==> Log Message
sLogFormat = DateTime.Now.ToShortDateString().ToString() + ” ” + DateTime.Now.ToLongTimeString().ToString() + ” ==> ”
‘this variable used to create log filename format ”
‘for example filename : ErrorLogYYYYMMDD
Dim sYear As String = DateTime.Now.Year.ToString()
Dim sMonth As String = DateTime.Now.Month.ToString()
Dim sDay As String = DateTime.Now.Day.ToString()
sErrorTime = sYear + sMonth + sDay
End Function
Well the problem is that in C# the function [COLOR=red]public CreateLogFiles()[COLOR=red]sw.WriteLine(sLogFormat + sErrMsg);
public void ErrorLog(string sPathName, string sErrMsg)
{
StreamWriter sw = new StreamWriter(sPathName+sErrorTime,true);
sw.WriteLine(sLogFormat + sErrMsg);
sw.Flush();
sw.Close();
}
How I can do that trick in VB.NET?
When I convert this to VB.NET it’s not working
public Sub ErrorLog(sPathName As String, sErrMsg As String)
Dim sw As New StreamWriter
sw = new StreamWriter(sPathName+sErrorTime,true)
sw.WriteLine(sLogFormat + sErrMsg)
sw.Flush()
sw.Close()
End Sub