Click here to Skip to main content
14,326,463 members
Rate this:
Please Sign up or sign in to vote.
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
Posted
Updated 21-Sep-18 22:30pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

See Where should I store my data?[^] for guidance on the best places to store application generated data.

As to the question "how to write messages in excel file in published exe file". You need to provide a proper explanation of what you are trying to do. Excel data is completely different from simple text.
   
Comments
Richard MacCutchan 22-Sep-18 6:34am
   
Sorry, but you need to provide some proper detailed information. We have no idea what is happening when you run the program.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100