• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

C# FTP Help Needed

Joined
Feb 11, 2008
Messages
537 (0.15/day)
Likes
164
Location
Lincoln, Nebraska, USA
System Name This PC
Processor Intel Core i7 2600K @ 4.8 GHz
Motherboard ASUS P8Z68 Deluxe
Cooling Custom Water Cooling - CPU Only
Memory 8GB (2 x 4GB) AData DDR3
Video Card(s) GTX 1080 TI - EVGA FTW3 - Slave BIOS
Storage Corsair Force GT 128GB / Samsung 850 Pro 512 GB
Display(s) AOC AGON AG271QG - 165 Hz - AHVA
Case Dimastech v2.5 Easy
Audio Device(s) Onboard
Power Supply Antec 1.2kW HCP
Mouse Logitech G403 - Wired
Keyboard Rosewill - MX Browns
Software Windows 10 Pro x64
#1
I have a program that I want to make that utilizes ftp to download and upload a file to a ftp server that I made using serversfree.com.

Here is the information that I have for the test account:
FTP IP: 185.28.21.34
FTP Hostname: joshuaserverconnect.com
FTP Username: u669041582
FTP Password: ••••••••••
FTP Port: 21
Folder to Upload Files: public_html
Here is my C# code. It is not completed yet, but there is no point in completing it yet if the first part does not work:
PHP:
WebClient request = new WebClient();

request.Credentials = new NetworkCredential("u669041582", "*********");

byte[] fileData = request.DownloadData("ftp://u669041582@185.28.21.34/public_html/Test.txt");
I get this error message when running my C# program:
The remote server returned an error: (550) File unavailable (e.g., file not found, no access).
However, using FileZilla, I can access the ftp server just fine. According to FileZilla, that text.txt file I am trying to download has that URL. I have even set permissions to include everybody. What am I doing wrong?
 
Last edited:

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
21,058 (6.22/day)
Likes
10,184
Location
IA, USA
System Name BY-2015
Processor Intel Core i7-6700K (4 x 4.00 GHz) w/ HT and Turbo on
Motherboard MSI Z170A GAMING M7
Cooling Scythe Kotetsu
Memory 2 x Kingston HyperX DDR4-2133 8 GiB
Video Card(s) PowerColor PCS+ 390 8 GiB DVI + HDMI
Storage Crucial MX300 275 GB, Seagate 6 TB 7200 RPM
Display(s) Samsung SyncMaster T240 24" LCD (1920x1200 HDMI) + Samsung SyncMaster 906BW 19" LCD (1440x900 DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay
Audio Device(s) Realtek Onboard, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse SteelSeries Sensei RAW
Keyboard Tesoro Excalibur
Software Windows 10 Pro 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
#2
I'm very certain WebClient only does HTTP. Try using FTPWebRequest:
http://msdn.microsoft.com/en-us/library/ms229715.aspx

You already gave the credentials so you shouldn't give them again in the URL.


Edit: MSDN says it does support it so I'd just try removing the user from the URL keeping Credentials or doing it all in the URL (username:password).

550 is permission denied.
 
Last edited by a moderator:
Joined
Feb 11, 2008
Messages
537 (0.15/day)
Likes
164
Location
Lincoln, Nebraska, USA
System Name This PC
Processor Intel Core i7 2600K @ 4.8 GHz
Motherboard ASUS P8Z68 Deluxe
Cooling Custom Water Cooling - CPU Only
Memory 8GB (2 x 4GB) AData DDR3
Video Card(s) GTX 1080 TI - EVGA FTW3 - Slave BIOS
Storage Corsair Force GT 128GB / Samsung 850 Pro 512 GB
Display(s) AOC AGON AG271QG - 165 Hz - AHVA
Case Dimastech v2.5 Easy
Audio Device(s) Onboard
Power Supply Antec 1.2kW HCP
Mouse Logitech G403 - Wired
Keyboard Rosewill - MX Browns
Software Windows 10 Pro x64
#3
I thank you for the response, but using the ftp web request nets me the same error, being that the program can not apparently find my file.

That in itself is awkward, because FileZilla is displaying my directory without problem. If that program is able to access my ftp server, why can't my c# program?
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
21,058 (6.22/day)
Likes
10,184
Location
IA, USA
System Name BY-2015
Processor Intel Core i7-6700K (4 x 4.00 GHz) w/ HT and Turbo on
Motherboard MSI Z170A GAMING M7
Cooling Scythe Kotetsu
Memory 2 x Kingston HyperX DDR4-2133 8 GiB
Video Card(s) PowerColor PCS+ 390 8 GiB DVI + HDMI
Storage Crucial MX300 275 GB, Seagate 6 TB 7200 RPM
Display(s) Samsung SyncMaster T240 24" LCD (1920x1200 HDMI) + Samsung SyncMaster 906BW 19" LCD (1440x900 DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay
Audio Device(s) Realtek Onboard, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse SteelSeries Sensei RAW
Keyboard Tesoro Excalibur
Software Windows 10 Pro 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
#4
I attached to this post the FtpClient I use in my programs. At its core, it uses FtpWebRequest but it also handles all the low level stuff that goes along with it (like setting the method). You'll also have to change the namespace in each of the files to suit your needs. I include instructions below for the MultithreadedFtpClient but if you don't want multithreading (highly recommended), you can use the FtpClient which is also in there.

You start it off with something like this (note the caps lock bits that need to be replaced):
Code:
        private MultithreadedFtpClient _Ftp = null;

        public Main()
        {
            InitializeComponent();

            RefreshListView();

            _Ftp = new MultithreadedFtpClient(DOMAIN_NAME, USER_NAME, PASSWORD);
            _Ftp.UploadProgressChanged += new UploadProgressChangedHandler(TransferProgressChanged);
            _Ftp.DownloadProgressChanged += new DownloadProgressChangedHandler(TransferProgressChanged);
            _Ftp.DownloadDone += new DownloadDoneHandler(TransferDone);
            _Ftp.UploadDone += new UploadDoneHandler(TransferDone);
        }
TransferProgressChanged looks something like this:
Code:
        private void TransferProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (this.InvokeRequired)
                this.Invoke(new DownloadProgressChangedHandler(TransferProgressChanged), this, e);
            else
            {
                FileInfo fi = new FileInfo(e.Source);
                UpdateListView(fi.Name, "Transfer", Math.Round((double)e.Transferred / (double)e.Available * 100, 0) + "%");
            }
        }
TransferDone looks something like this:
Code:
        private void TransferDone(object sender, DoneEventArgs e)
        {
            if (this.InvokeRequired)
                this.Invoke(new DownloadDoneHandler(TransferDone), this, e);
            else
            {
                FileInfo fi = new FileInfo(e.Instructions.Source);
                UpdateListView(fi.Name, "Transfer", "100%");
                started--;

                if (started == 0)
                {
                    lblMessage.Text = "Transfer complete.";
                    Done();
                }
            }
        }
An upload is as simple as:
Code:
_Ftp.Upload(LOCAL, REMOTE);
A download is as simple as:
Code:
_Ftp.Download(REMOTE, LOCAL, OVERWRITE);
I'm hoping that will take care of it for you. I use it on a near daily basis to write files to a secure Active Directory/IIS FTP server.
 

Attachments

Last edited:
Joined
Feb 11, 2008
Messages
537 (0.15/day)
Likes
164
Location
Lincoln, Nebraska, USA
System Name This PC
Processor Intel Core i7 2600K @ 4.8 GHz
Motherboard ASUS P8Z68 Deluxe
Cooling Custom Water Cooling - CPU Only
Memory 8GB (2 x 4GB) AData DDR3
Video Card(s) GTX 1080 TI - EVGA FTW3 - Slave BIOS
Storage Corsair Force GT 128GB / Samsung 850 Pro 512 GB
Display(s) AOC AGON AG271QG - 165 Hz - AHVA
Case Dimastech v2.5 Easy
Audio Device(s) Onboard
Power Supply Antec 1.2kW HCP
Mouse Logitech G403 - Wired
Keyboard Rosewill - MX Browns
Software Windows 10 Pro x64
#5
Thank You for all of your assistance Ford, but the problem was just the people I was using to host my ftp server.

I finally decided to pay GoDaddy (not too expensive) for a hosting site, and everything is working as it should.
 
Joined
Feb 18, 2014
Messages
2 (0.00/day)
Likes
0
#6
Thank You for all of your assistance Ford, but the problem was just the people I was using to host my ftp server.

I finally decided to pay GoDaddy (not too expensive) for a hosting site, and everything is working as it should.
I have the same issue with serversfree.com. May I know what product of GoDaddy did you actually purchased? Is it their web hosting?
 
Last edited by a moderator:
Joined
Feb 11, 2008
Messages
537 (0.15/day)
Likes
164
Location
Lincoln, Nebraska, USA
System Name This PC
Processor Intel Core i7 2600K @ 4.8 GHz
Motherboard ASUS P8Z68 Deluxe
Cooling Custom Water Cooling - CPU Only
Memory 8GB (2 x 4GB) AData DDR3
Video Card(s) GTX 1080 TI - EVGA FTW3 - Slave BIOS
Storage Corsair Force GT 128GB / Samsung 850 Pro 512 GB
Display(s) AOC AGON AG271QG - 165 Hz - AHVA
Case Dimastech v2.5 Easy
Audio Device(s) Onboard
Power Supply Antec 1.2kW HCP
Mouse Logitech G403 - Wired
Keyboard Rosewill - MX Browns
Software Windows 10 Pro x64
#7
I had a server from GoDaddy, but had issues with them. I ultimately made an account with http://www.onlinestoragesolution.com/ for $19 a year, and it works perfectly for what I want.
 
Joined
Feb 18, 2014
Messages
2 (0.00/day)
Likes
0
#8
I had a server from GoDaddy, but had issues with them. I ultimately made an account with http://www.onlinestoragesolution.com/ for $19 a year, and it works perfectly for what I want.
What specific product of GoDaddy is that? May I ask for a link of it? And what problem did yout encounter?

The thing is I'll be uploading data from an Arduino using a GSM/GPRS module without any PC help. Do you think GoDaddy and OnlineStorageSolution permits that because I think with ServersFree, they just permit uploading of files usinh FilleZilla. I may be wrong though.
 
Joined
Feb 11, 2008
Messages
537 (0.15/day)
Likes
164
Location
Lincoln, Nebraska, USA
System Name This PC
Processor Intel Core i7 2600K @ 4.8 GHz
Motherboard ASUS P8Z68 Deluxe
Cooling Custom Water Cooling - CPU Only
Memory 8GB (2 x 4GB) AData DDR3
Video Card(s) GTX 1080 TI - EVGA FTW3 - Slave BIOS
Storage Corsair Force GT 128GB / Samsung 850 Pro 512 GB
Display(s) AOC AGON AG271QG - 165 Hz - AHVA
Case Dimastech v2.5 Easy
Audio Device(s) Onboard
Power Supply Antec 1.2kW HCP
Mouse Logitech G403 - Wired
Keyboard Rosewill - MX Browns
Software Windows 10 Pro x64
#9
The link to the GoDaddy product that I used is here: http://www.godaddy.com/hosting/web-hosting-new.aspx?ci=87227

I had a multitude of problems with GoDaddy. Apparently, I was doing something "illegal" by just purchasing the hosting. Apparently to make a FTP server with them, I also needed to purchase their Virtual Private Network. That was becoming costly for something that I would be using on the side just to teach myself some programming principles.

Also, the GoDaddy FTP server address used a naming convention that I could never get to work with C Sharp. I do not remember the exact address, or what made it awkward, but the physical address itself contained certain characters that would make Visual Studio freak out.

So, I used Online Storage Solutions, which was cheap. I believe it was 19 USD for one entire year.

As far as if it will work for you, I can not tell you for sure. I use it to store to and retrieve from .txt files that I use in my C Sharp programs. It works flawlessly.