C # programs automatically update software version numbers

Source: Internet
Author: User

Recently because the server program management, so when viewing the server program, only through the EXE compile time to determine the server program version time, The Trouble kills

Now think of a way, in the directory to add a version file, which is written on the date of month and year, and only in the program debugging compile to update the version file, in order to achieve the purpose of recording program version number

1   if(debugger.isattached)//to determine whether to debug the compilation, then write the current month and date to the file2             {3                 using(FileStream file =NewFileStream (Application.startuppath +"\\version", FileMode.OpenOrCreate))4                 {5                     byte[] data = Encoding.Default.GetBytes (DateTime.Now.Year +""+ DateTime.Now.Month.ToString ("xx") +""+ DateTime.Now.Day.ToString ("xx"));6File. Write (data,0, data. Length);7                 }8             }9             //gets the version number of the file, which is displayed to the program window each time the form is openedTen             using(FileStream file =NewFileStream (Application.startuppath +"\\version", FileMode.OpenOrCreate)) One             { A                 byte[] Bydata =New byte[ -]; -File. Seek (0, seekorigin.begin); -File. Read (Bydata,0, -); the                 stringA ="V"+ Encoding.Default.GetString (bydata). Trim (' /'); -                  This. Text + =A; -}

function is very simple, but very practical, crossing do not spray, free to play

C # programs automatically update software version numbers

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: info-contact@alibabacloud.com 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.