Given $\large\frac{dy}{dx}$$+y=e^{-x}$
Clearly this is a linear differential equation of the form $ \large\frac{dy}{dx}$$+Py=Q$ where $P$ and $Q$ are $ 1$ and $e^{-x}$ respectively
The solution to this equation is
$y.e^{\int pdx}=\int Q.e^{\int pdx}+c$
Where $ e^{\int pdx} $ is the integrating factor(I.F)
$\int pdx=\int dx$ on integrating we get
$=x$
Hence $I.F=e^{\int pdx}=e^x$
Now the required solution is
$ye^x=\int e^{-x}.e^xdx+c$
$=> ye^{x}=\int dx+c$
On integrating we get
$ye^x=x+c$
It is given $y(0)=0=>when \;x=0,y=0$
Now substituting the value of x and y we get,
$0.e^x=0+c$
Hence the solution is
$ye^x=x=>y=xe^{-x}$
Hence the correct option is $D$