rendertexture how to?

hi, im trying to make a screenshot of a camera and save it as a .png

but i dont get it, how to set up the render texture.
my program just crashes.

thx

thats the code,attached to a camera :

var thumbnail = new RenderTexture(512,512,24);

function Update () {
gameObject.Find(“thumbCam”).camera.Render();
RenderTexture.active = thumbnail; //thumbnail is a RenderTexture
var thumb_tex = new Texture2D(512, 512);
thumb_tex.ReadPixels(gameObject.Find(“thumbCam”).camera.pixelRect,0,0);
RenderTexture.active = null;
thumb_tex.Apply();
var png : byte[ ] = thumb_tex.EncodeToPNG();
System.IO.File.WriteAllBytes(Application.dataPath + “/…/SavedScreen.png”, png);
}

you are on unity pro? cause with the free one, render textures are no usable

yes i am

i dont know what i did wrong.
now it works.

ty