Moved try from a method implemented at common level to specific level in
each platform. As well as preparation work for C# Write file