What's the best way to reference a file path for ReadAllBytes?

Hi, I'm using VS2013, C# and asp.net webform
I need to read in a Word file into a byte[] using ReadAllBytes().  Should I add this Word file to my project?  If I add this word file (maybe a folder too?) to the project then how can I put as file path for the ReadAllBytes()?  
I really don't like using the hard coded c:\xxx\yyy.docx   unless I must.  I mean when I publish this to the web server the path will change so hard cording path doesn't seem like a good idea to me.
thank you.
lapuccaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
>>I mean when I publish this to the web server the path will change so hard cording path doesn't seem like a good idea to me.

so... you still can put the file into a folder in your website and then read the path of the file relatively.

for example you can use Server.MapPath to returns the "physical path" of the server, which is "relative" in your codes (meaning you no need to hardcode it in your codes)

HttpServerUtility.MapPath Method
https://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath(v=vs.90).aspx

similarly, you can also refer to:

HttpRequest.ApplicationPath Property
https://msdn.microsoft.com/en-us/library/system.web.httprequest.applicationpath.aspx

HostingEnvironment.ApplicationPhysicalPath Property
https://msdn.microsoft.com/en-us/library/system.web.hosting.hostingenvironment.applicationphysicalpath.aspx

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MlandaTCommented:
You just use


File.ReadAllBytes(Server.MapPath("~/folder/file.docx"))

The ~ means from the root folder of your application. The folder you specify in IIS when setting  up the application
lapuccaAuthor Commented:
Thank you, that worked.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.