Determination of D-meson lifetimes