martes, 5 de mayo de 2015

C# - Fecha Automática para las Publicaciones

 //Solo Fecha
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var fechaPublish = "01/01/1900";
                var dll = Server.MapPath("bin\\DLLNombre.dll");
                if (File.Exists(dll))
                    fechaPublish = File.GetLastWriteTime(dll).ToString("dd-MM-yyyy hh:mm") + " HRS.";
                lblFechaLiberacion.Text = fechaPublish;
            }
        }

        //Fecha + string de conexión
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var dataSource = System.Configuration.ConfigurationManager.ConnectionStrings["NombreConexion"].ConnectionString.Split(';').ToArray();
                string data = dataSource[0].Replace("Data Source=", "");
                var dll = Server.MapPath("bin\\DLLNombre.dll");

                if (File.Exists(dll))
                    data += " - " + File.GetLastWriteTime(dll).ToString();
                lblInfo2.Text = data;
            }
        }

No hay comentarios:

Publicar un comentario