What is the problem with this reasoning?
$$ \intop_0^K f(x)dx = \intop_0^{\infty}I(x\leq K)f(x)dx.$$
Using integration by parts with $u=I(x\leq K)$ and $\frac{dv}{dx}=f(x)$, we have:
$$\intop_0^K f(x)dx = [uv]_0^{\infty} - \intop_0^{\infty}v\frac{du}{dx} dx.$$
Since $u$ is the indicator function, its derivative is the negative dirac delta function $-\delta(x-K)$, and we have.
$$\intop_0^K f(x)dx = [uv]_0^{\infty} + \intop_0^{\infty}v\delta(x-K)dx = [uv]_0^{\infty} + v(K),$$
where $v(K)$ is the function $v$ evaluated at $K$.