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 6243179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:05:28+00:00 2026-05-24T12:05:28+00:00

i got a server host that only let me upload files through ftp (with

  • 0

i got a server host that only let me upload files through ftp (with code in my application).
so i got a code that works and lets me upload files to the server except with one strange thing, i can not upload files if me/user is logged in (authenticated). this is a shot in the dark to see if anybody maybe know why this is.

my error message is this

Access to the path 'D:\hshome\PATH' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj) at System.IO.Directory.CreateDirectory(String path) at BasicProject.Mvc.Areas.Account.Controllers.ProfileController.Test(TestViewModel viewModel)

my code i use for the upload is this

foreach (string item in Request.Files)
                {
                    HttpPostedFileBase file = Request.Files[item];
                    if (file != null)
                    {
                        var path = "File";
                        var filePath = System.Web.HttpContext.Current.Server.MapPath("~/" + path + "/");

                        if (!Directory.Exists(filePath))
                            Directory.CreateDirectory(filePath);

                        FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://SITE/SITE/" + path + "/" + file.FileName);
                        request.Method = WebRequestMethods.Ftp.UploadFile;

                        request.Credentials = new NetworkCredential("USER", "PASSWORD");
                        request.UsePassive = false;

                        var sourceStream = new StreamReader(file.InputStream);
                        byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
                        sourceStream.Close();
                        request.ContentLength = fileContents.Length;

                        Stream requestStream = request.GetRequestStream();
                        requestStream.Write(fileContents, 0, fileContents.Length);
                        requestStream.Close();

                        FtpWebResponse response = (FtpWebResponse)request.GetResponse();                        

                        response.Close();

                    }

like i said this works if i dont login and its a shot in the dark if you had the same issue i would be more then happy to get a piece of the solution.

  • 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-24T12:05:30+00:00Added an answer on May 24, 2026 at 12:05 pm

    The problem was that i could not create the folder while being authenticated, so in this specific case i create folders for users when they register, and using the ftp upload code i show above its working good.

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

Sidebar

Related Questions

We've got a Java server application that runs on a number of computers, all
So I've got this server application running on Google AppEngine that I want to
I've got a piece of tracking code which is capturing REMOTE_HOST , SERVER ,
I've got an Apache server that has one access log file that is topping
We've got a Windows Server 2003 running IIS 6 where we host multiple sites
I've got build server running CruiseControl.NET and recently it started throwing this error on
We've got VisualSVN Server set up as our Subversion server on Windows, and we
We've got a server over which we're running a Django powered site. Since we
We got a TeamCity server which produces nightly deployable builds. We want our beta
Recently we got a new server at the office purely for testing purposes. It

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.