1. Create folder Properties in ProjectDir

  2. In tab Resources of project properties, add a new text file

  3. Add command to pre-build event

   echo %date% %time% > "$(ProjectDir)\Resources\BuildDateTime.txt"
   
  1. In code retrieve
   string x = Properties.Resources.BuildDateTime;