Winfrom Storing TXT log functions

Source: Internet
Author: User

Refer to the code of the Payment SDK, extract the WinForm storage Notepad log function:

        #regionStorage Log Public stringPath = Application.startuppath +"/logs"; Private voidWritelog (stringTypestringClassName,stringcontent) {            if(! Directory.Exists (PATH))//If the log directory does not exist, create{directory.createdirectory (path); }            stringTime = DateTime.Now.ToString ("YYYY-MM-DD HH:mm:ss.fff");//get current system time            stringfilename = path +"/"+ DateTime.Now.ToString ("YYYY-MM-DD") +". Log";//Name the log file by date//Create or open a log file to append records to the end of the log fileStreamWriter MYSW =file.appendtext (filename); //writing to a log file            stringWrite_content = time +" "+ Type +" "+ ClassName +": "+content;            Mysw.writeline (write_content); //Close log fileMysw.close (); }        #endregion

Winfrom Storing TXT log functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.