Hi, I want to use server.mappath to get virtual path of a file, but the function cannot be used in a class file...please advise.

There is one way by which you can declare a string globally, if you want that then you can follow the below way.
1. Double Click the Project in Solution Explorer,
2. Project properties will open
3. goto settings
4. Set Global Variable From there
like Select String, Select Application, And define path.
after that save it.

after saving you will see that there will be app.config file appear in solution bar.
In your application you can call that string by.

My.Settings.Text ' where text is global string

hope this can help u in near future.

but your question server.mappath doesnt work now instead try to see details for "defpath"