Generally Server.MapPath works in the code behind page but if we move to class file, it expects the namespace to be used and by default it doesn't exists in the class file. So use prefix it with HttpContext.Current and it will work.
HttpContext.Current.Server.MapPath("~/mypath"); Thank you