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