Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7510975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:23:57+00:00 2026-05-29T23:23:57+00:00

I have looked around the internet for 3 hours now looking for a solution

  • 0

I have looked around the internet for 3 hours now looking for a solution to my problem and I’m starting to wonder if anyone else has ever had this exact problem?

I am using IIS7 to host a website that does some local things around our office. Well, developing the site everything worked fine, but now that I am hosting the site I cannot (and neither can anyone else for that matter) click on the link to download the file that is needed. (lets just pretend they click on a link to download some random file from the webserver)

Well, it fails downloading the file from what I can guess as being a permissions error. I have looked for a solution but cannot seem to find one. I know very little about IIS7 so I do not understand very much about the Application Pool Identity stuff, although I did manage to grant full access for that identity to the file/folders. Anyways, here is the specific area it is messing up on..

This is a piece of the default.cshtml page that calls a Function from a .cs file:
//well.. pretty close to the exact thing, just got rid of a bunch of unecessary junk

@{
string tmp = Functions.downloadFile(fileName)
}

<html>
tmp
</html>

This is the part of the .cs file that actually downloads the file to the desktop

public static string downloadFile(string fileName) //i know this example doesnt 
//use filename, but the original code does.
{
    if (Directory.Exists("C:\WebSite\thingsToDownload"))
    {
        string[] files = Directory.GetFiles("C:\WebSite\thingsToDownload");

        foreach (string s in files)
        {
            string[] tmp = s.Split('\\');
            try
            {
                File.Copy(s,
                          Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                          + "\\" + tmp[tmp.Length - 1]);
            }
            catch (Exception e)
            {
                return "ERROR COPYING: " + e.Message;
            }
        }
        return "GOOD";
    }
    return "DIRECTORY DOESNT EXIST";
}

After that is all said and done, i get “ERROR COPYING: Access to the path ‘\fileName’ is denied.

My Guess is that the webserver does not have access to the person’s desktop in order to put the files there.
If anyone can shed some light and help me get this it would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:24:00+00:00Added an answer on May 29, 2026 at 11:24 pm

    If you want to download a file by clicking a link you should use response.

    Here’s a sample you can use for example when a user clicks a link or button or something:

      const string fName = @"C:\picture.bmp";
      FileInfo fi = new FileInfo(fName);
      long sz = fi.Length;
    
      Response.ClearContent();
      Response.ContentType = Path.GetExtension(fName);
      Response.AddHeader("Content-Disposition", string.Format("attachment; filename = {0}",System.IO.Path.GetFileName(fName)));
      Response.AddHeader("Content-Length", sz.ToString("F0"));
      Response.TransmitFile(fName);
      Response.End();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked around for a solution to this problem, but it's so wonky
I have looked around and have yet to find a solution to this problem.
I have looked around on the Internet trying to answer this question. It seems
I've looked around the internet and haven't quite found what I'm looking for. I
I have looked around here to see if somebody has asked this question before
I have looked around stackoverflow and search the internet but did not find a
I have looked around to find a solution for setting the background color of
I have a rails 3 application and looked around in the internet for daemons
I have looked around the internet but haven't been able to find a working
I have looked around SO and the web for quite some time now and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.