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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:42:32+00:00 2026-06-10T21:42:32+00:00

I have the following code to perform FTP file: private bool InitFTPTransfer(string filePath) {

  • 0

I have the following code to perform FTP file:

    private bool InitFTPTransfer(string filePath)
    {
        Uri ipAddress = new Uri(ddcdao.ddcAddress);

        string ftpAddress = "ftp://10.175.95.11/mnt/flash" +Path.GetFileName(filePath);
        FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpAddress);
        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();
        return true;
    }

The file transfers without a problem but the file is placed on the root, not at the designated directory (/mnt/flash).

I was under the impression that specifying a directory in ftp address should set the destination properly but this may not be true for embedded linux.

How can I fix this issue?

  • 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-10T21:42:34+00:00Added an answer on June 10, 2026 at 9:42 pm

    The path appears to be correct. However:

    1. URL encode the file name first to escape any invalid characters.
    2. The code is missing a slash (/) between the folder and the file name. This may cause the path to be invalid, causing it to write to the root folder.
    3. Use using or try…finally blocks to close the various streams in case an exception is thrown.
    4. Use stream.CopyTo (see How do I copy the contents of one stream to another?) instead of reading the whole file in. This may have issues if the files are particularly large.

    The problem is likely on the FTP server configuration side. The FTP server appears to be serving up the root folder of the file system as its root folder which is a bad practice. The FTP server should only serve up the folders files should be downloaded from or uploaded to. However, this may be a feature of the configuration on the embedded Linux you are using.

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

Sidebar

Related Questions

I have written the following code to perform some simultaneous HTTP posting and file
I have the following code : System.out.println(new String(–’.getBytes(ISO8859_15_FDIS))); The two characters in the first
I have the following code: public boolean perform(CronJob job) final Date lastQueryDateTime = new
I have following code to perform some regular expression on the string public class
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { using
The following code is intended to retrieve a file via FTP. However, I'm getting
I have the following code to perform validation of SubmitForm shown below on click
I have the following code: ServiceSoapClient service = new ServiceSoapClient(); var dataSource = (from
I have the following code. I would like to perform a if then check
I have the following code: public class ClassExample { void DoSomthing<T>(string name, T value)

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.