I'm trying to get the LastLogon from a user in the active directory but I have this code
lblUsernameDisplay.Text = "LastLogon : " + (DateTime.FromFileTime((long)rs.GetDirectoryEntry().Properties["lastLogon"][0])).ToString();
And I got an error, I also tried without long cast, without ToString() and with .Value.ToString() instead of [0]
UPDATE:
I got this error: Specified cast is not valid.