Create .png asset

Can anybody help check whats wrong with my code, the error given is:
Could not create texture from Assets/Textures/1x1 0,0,0.png: File could not be read

EDIT: Got it working, changed the code below. (This is a editor only script)

void CreateColorPicture(Color color) {
	Texture2D tex = new Texture2D(1,1);
	tex.SetPixel (1, 1, color);
	tex.Apply();
	
	if(!Directory.Exists(Application.dataPath+"/Textures/")) {
		Directory.CreateDirectory(Application.dataPath+"/Textures/");
	}

	byte[] bytes = tex.EncodeToPNG();
	DestroyImmediate(tex);
	File.WriteAllBytes (Application.dataPath + "/Textures/1x1 "+(color.r * 255).ToString()+","+(color.g * 255).ToString()+","+(color.b * 255).ToString()+".png", bytes);
}

It is meant to create a 1x1 picture with the given color.

That’s not a .png, it’s a Texture2D. Unity does not use .png, .jpg, or any other format like that. As the docs for CreateAsset say: “You must ensure that the path uses a supported extension (‘.mat’ for materials, ‘.cubemap’ for cubemaps, ‘.GUISkin’ for skins, ‘.anim’ for animations and ‘.asset’ for arbitrary other assets.)”