7 Replies - 400 Views - Last Post: 15 March 2019 - 03:51 AM Rate Topic: -----

#1 ssagp   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 01-March 19

Log file creation

Posted 08 March 2019 - 02:11 AM

How to create log files in C# for windows application.
I have to create log files for uploading files and to submit the file in my application/

 private void btn_pos35_Click(object sender, EventArgs e)
        {
            int btncount = 34;
            openFileDialog1.Filter = "BIN files (*.BIN)|*.BIN";
            openFileDialog1.FilterIndex = 2;
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                checkifselected(filenames, openFileDialog1.FileName, lbl_pos35, btncount);
            }
        }

submit button

   private void btn_submit_Click(object sender, EventArgs e)
        {
            if (serialPort2.IsOpen == true)
            {
                richTextBox1.Text = "";
                readThread = new Thread(new ThreadStart(ExecuteBinFile));
                if (true != readThread.IsAlive)
                    readThread.Start();
            }
            else
            {
                MessageBox.Show("No device connected.");
                return;
            }
        }


This post has been edited by andrewsw: 08 March 2019 - 03:19 AM
Reason for edit:: fixed botched [code][/code] tags


Is This A Good Question/Topic? 0
  • +

Replies To: Log file creation

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6805
  • View blog
  • Posts: 28,134
  • Joined: 12-December 12

Re: Log file creation

Posted 08 March 2019 - 03:55 AM

This question is too broad and lacks details.

What type of application is this?
What do you need to log? Every activity of your application?
Where do you need to log?

Are you going to write to a file yourself or would you use a library?
Was This Post Helpful? 0
  • +
  • -

#3 ssagp   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 01-March 19

Re: Log file creation

Posted 08 March 2019 - 04:19 AM

I need to log every activity to a text file

This post has been edited by andrewsw: 08 March 2019 - 04:19 AM
Reason for edit:: removed previous quote, use the Reply button

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6805
  • View blog
  • Posts: 28,134
  • Joined: 12-December 12

Re: Log file creation

Posted 08 March 2019 - 04:20 AM

Is there some reason that you are reluctant to be more forthcoming with information?

Please respond to my other questions, and add any other information that you think might be pertinent.
Was This Post Helpful? 0
  • +
  • -

#5 ssagp   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 01-March 19

Re: Log file creation

Posted 08 March 2019 - 05:07 AM

This is a windows application in c# which includes uploading some files and submitting these files to the application.

This post has been edited by andrewsw: 08 March 2019 - 05:49 AM
Reason for edit:: you do not have to quote the previous post, use the REPLY button

Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6805
  • View blog
  • Posts: 28,134
  • Joined: 12-December 12

Re: Log file creation

Posted 08 March 2019 - 05:51 AM

Given the lack of discourse I will just say either investigate "c# write to text file" or "c# logging library".

(Actually, I note that you posted in ASP.NET so that is at least one part of my questions answered.)
Was This Post Helpful? 0
  • +
  • -

#7 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2906
  • View blog
  • Posts: 11,325
  • Joined: 03-December 12

Re: Log file creation

Posted 08 March 2019 - 06:03 AM

There are a host of logging tools available for .net.

https://www.nuget.or...ckages/log4net/
https://stackify.com...dotnet-logging/

Is one I use currently. You don't need to reinvent the wheel.
Was This Post Helpful? 1
  • +
  • -

#8 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 6985
  • View blog
  • Posts: 23,746
  • Joined: 05-May 12

Re: Log file creation

Posted 15 March 2019 - 03:51 AM

Also, if this is a C# Windows application, why are you posting the question in ASP.NET?

Moving to C#...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1