How to create and save material instances to the specified directory when the engine is running

How to create and save material instances to the specified directory when the engine is running?

I created a material instance at runtime, then adjusted the material parameters of this instance, now I want to create this adjusted material instance to the specified directory, how do I do it?