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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:29:57+00:00 2026-06-11T00:29:57+00:00

Possible Duplicate: How do you change directories using FtpWebRequest (.NET)? private void InitFTPTransfer(string filePath)

  • 0

Possible Duplicate:
How do you change directories using FtpWebRequest (.NET)?

    private void InitFTPTransfer(string filePath)
    {
        string[] ftpAddress = ddcdao.ddcAddress.Split(new string[] { "http://" }, StringSplitOptions.None);
        FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://" + ftpAddress[1] + "/root/" + Path.GetFileName(filePath));
        request.Method = WebRequestMethods.Ftp.UploadFile;

        request.Credentials = new NetworkCredential(Properties.Settings.Default.SysFTPID, Properties.Settings.Default.SysFTPPassword);

        byte[] fileContents = File.ReadAllBytes(filePath);

        request.ContentLength = fileContents.Length;

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

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

        response.Close();

    }

I have the above code to upload a particular file to a path.

Inside the ftp, how do I set a particular directory to upload the file on?

In this case, I’m uploading to a machine with embedded linux so it needs to be under /root/somedirectory

Edit: I’ve tried the suggestions of actually including the directory path in the request path but it just throws a System.Net.WebException with the message “System error” on the line of request.GetRequestStream();

  • 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-06-11T00:29:58+00:00Added an answer on June 11, 2026 at 12:29 am

    You put the directory in the request’s path, i.e.

    FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://" 
                             + ddcdao.ddcAddress + "/" + someDirectory 
                             + "/" someFile);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: i cant change static void Main(string[] args) Hi, when I change static
Possible Duplicate: Can I change a private readonly field in C# using reflection? I
Possible Duplicate: Change the URL in the browser without loading the new page using
Possible Duplicate: How to change the number of rows in the textarea using jQuery
Possible Duplicate: View the change history of a file using Git versioning Sometimes I
Possible Duplicate: If string only contains spaces? I do not want to change a
Possible Duplicate: How to change the href for a hyperlink using jQuery I have
Possible Duplicate: How does Windows change Aero Glass color? using c# how do you
Possible Duplicate: How to change the href for a hyperlink using jQuery I have
Possible Duplicate: How to change an input button image using CSS? Is it possible

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.