1

I am having issues with my IT team and they are unaware of how to handle my request. I have asked them to add Network Service to a folder that my asp.net site needs to have access to in order to open an excel template and populate it with data. I have been trying to get this done for multiple weeks now and I am very frustrated.

So here is my question. I have looked online and cannot find a way to do this. If I were to put the template file in my website, as a folder like an image, is there a way to dynamically reference that template in code behind? That way the application has access to the file. The user is saving the report to their own folders, so I don't ever need them to have access to the file directly.

Please advise. Any suggestions will help.

3
  • Just chmod(777) the folder - full read, write, execute permissions. Seems to me the problem would be more based off of actually interacting with the .xls(x) file than it would having access to the physical folder location. That interaction is a whole other ball game. Commented Mar 30, 2012 at 17:06
  • If you know where the file is in your web structure, then Server.MapPath("~/path_to_file.xslx") will give you the local path on the server, if that's what you are after? The ~/path_to_file.xsl(x) bit will be a folder under your webroot. Commented Mar 30, 2012 at 17:08
  • THANK YOU DASH! Server.MapPath worked great. Accessed it both in local and server versions. Commented Mar 30, 2012 at 17:18

1 Answer 1

1

If you place the file in a local folder under your webroot, then using Server.MapPath will enable you to obtain a local path for the file.

For example,

Server.MapPath("~/templates/mytemplate.xslx")

Would translate to something like C:\inetpub\wwwroot\mysite\templates\mytemplate.xslx

Then you can do whatever you want with your template!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.