International audienceWe employ recently published cross sections for D mesons with hadrons and calculate the drag and diffusion coefficients of D mesons in hadronic matter as a function of the momentum of D mesons as well as of the temperature of the medium. Calculating in our approach the spatial diffusion coefficient, D-x, at zero chemical potential we see a very smooth transition between our calculations for the hadron gas and the lattice QCD calculations. Applying the results for the transport coefficients of D mesons in a Fokker-Planck equation, which describes the evolution of D mesons during the expansion of a hadron gas created in ultrarelativistic heavy-ion collisions, we find that the value of R-AA is little influenced by hadronic rescattering, whereas in the elliptic flow the effects are stronger. We extend our calculations to the finite chemical potentials and calculate the spatial diffusion coefficients of D mesons propagating through the hadronic medium following isentropic trajectories, appropriate at future FAIR (Facility for Antiproton and Ion Research, Darmstadt) and NICA (Nuclotron-Based Ion Collider Facility, Dubna) heavy-ion experiments. For the isentropic trajectory with s/rho(net)(B) = 20 we find a perfect matching of results for D mesons in hadronic matter and for charm quarks in partonic matter treated within the dynamical quasiparticle model approach