I write this code for TCP listener that get message will be stored in text as log file
it working in Visual Studio development but I publish no file will be created or not stored messages from client
void server_DataReceived(object sender, SimpleTCP.Message e)
{
try
{
txtStatus.Invoke((MethodInvoker)delegate()
{
e.ReplyLine(string.Format("\r\n CLIENT:>>{0}\r\n", e.MessageString));
CommonControls.writeToLogFile(string.Format("{0}\r\n", e.MessageString));
});
}
catch (SocketException e1)
{
output = "SocketException: " + e1.ToString();
}
}
and the write in text file
public static void writeToLogFile(string logMessage)
{
string strLogMessage = string.Empty;
string strLogFile = System.Configuration.ConfigurationSettings.AppSettings["logFilePath"].ToString();
StreamWriter swLog;
strLogMessage = string.Format("{0}: {1}", DateTime.Now, logMessage);
if (!File.Exists(strLogFile))
{
swLog = new StreamWriter(strLogFile);
}
else
{
swLog = File.AppendText(strLogFile);
}
swLog.WriteLine(strLogMessage);
swLog.WriteLine();
swLog.Close();
}
as well as i need how to write messages in excel file in published exe file
What I have tried:
i tried in C# Visual Studio by saving logfile when it is BIN folder but how to get when it is Publish EXE file
Thanks in advance