You do realize that the majority of your code is completely useless, don't you? The only effective code you have there is:
public byte[] pstFile(HttpPostedFile hf)
{
BinaryReader a = new BinaryReader(hf.InputStream);
return a.ReadBytes(hf.ContentLength);
}
So I suspect that if this worked in a different application, it was because it wasn't anything like the code you are showing us...