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

  • SEARCH
  • Home
  • 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 7218323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:28:01+00:00 2026-05-28T21:28:01+00:00

I have a return a c# code to save a file in the server

  • 0

I have a return a c# code to save a file in the server folder and to retrieve the saved file from the location. But this code is working fine in local machine. But after hosting the application in IIS, I can save the file in the desired location. But I can’t retrieve the file from that location using

Process.Start

What would be the problem? I have searched in google and i came to know it may be due to access rights. But I don’t know what would be exact problem and how to solve this? Any one please help me about how to solve this problem?

To Save the file:

string hfBrowsePath = fuplGridDocs.PostedFile.FileName;
if (hfBrowsePath != string.Empty)
{
    string destfile = string.Empty;
    string FilePath = ConfigurationManager.AppSettings.Get("SharedPath") + ConfigurationManager.AppSettings.Get("PODocPath") + PONumber + "\\\\";
    if (!Directory.Exists(FilePath.Substring(0, FilePath.LastIndexOf("\\") - 1)))
       Directory.CreateDirectory(FilePath.Substring(0, FilePath.LastIndexOf("\\") - 1));
    FileInfo FP = new FileInfo(hfBrowsePath);

    if (hfFileNameAutoGen.Value != string.Empty)
    {
        string[] folderfiles = Directory.GetFiles(FilePath);
        foreach (string fi in folderfiles)
        File.Delete(fi);
        //File.Delete(FilePath + hfFileNameAutoGen.Value);
    }
    hfFileNameAutoGen.Value = PONumber + FP.Extension;
    destfile = FilePath + hfFileNameAutoGen.Value;
    //File.Copy(hfBrowsePath, destfile, true);
    fuplGridDocs.PostedFile.SaveAs(destfile);
}

To retrieve the file:

String filename = lnkFileName.Text;
string FilePath = ConfigurationManager.AppSettings.Get("SharedPath") + ConfigurationManager.AppSettings.Get("PODocPath") + PONumber + "\\";
FileInfo fileToDownload = new FileInfo(FilePath + "\\" + filename);
if (fileToDownload.Exists)
     Process.Start(fileToDownload.FullName);
  • 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-28T21:28:01+00:00Added an answer on May 28, 2026 at 9:28 pm

    It looks like folder security issue. The folder in which you are storing the files, Users group must have Modify access. Basically there is user(not sure but it is IIS_WPG) under which IIS Process run, that user belongs to Users group, this user must have Modify access on the folder where you are doing read writes.

    Suggestions

    • Use Path.Combine to create folder or file path.
    • You can use String.Format to create strings.
    • Create local variables if you have same expression repeating itself like FilePath.Substring(0, FilePath.LastIndexOf("\\") - 1)

    Hope this works for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have the following code: return from a in DBContext.Acts join artist in
I want to download a file from server to a local host. i have
I have an object that downloads a file from a server, saves it into
I'm trying to convert an .avi video file I have in my server folder
I tried uploading an audio file from android client to server but I'm getting
Is it possible to have the router return an error code (or an entire
Let's say I have int a() { /* Tons of code ....*/ return someInt;
I just realized that in some place in my code I have the return
I have some VERY simple code to return the title for a section header:
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public

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.