• 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
607 (0.10/day)
Location
Omaha, Nebraska, USA
System Name Built By Me
Processor Intel Core i9 9900K @ 5.1 GHz
Motherboard Gigabyte Z390 Aorus Ultra
Cooling Custom Water Cooling - CPU Only
Memory 32GB (2 x 16) GSkill Ripjaws V DDR4
Video Card(s) RTX 4080 - ASUS ROG Strix 16GB OC - P Mode
Storage 1TB Samsung 970 Evo NVMe
Display(s) Alienware AW2723DF @ 280 Hz @ 1440P
Case Fractal Design Define S2
Audio Device(s) Corsair Virtuoso Pro
Power Supply 850W Seasonic Platinum
Mouse Razer Viper V2 Pro @ 2k Hz
Keyboard Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches
Software Windows 11 Pro
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
26,259 (4.64/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
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
607 (0.10/day)
Location
Omaha, Nebraska, USA
System Name Built By Me
Processor Intel Core i9 9900K @ 5.1 GHz
Motherboard Gigabyte Z390 Aorus Ultra
Cooling Custom Water Cooling - CPU Only
Memory 32GB (2 x 16) GSkill Ripjaws V DDR4
Video Card(s) RTX 4080 - ASUS ROG Strix 16GB OC - P Mode
Storage 1TB Samsung 970 Evo NVMe
Display(s) Alienware AW2723DF @ 280 Hz @ 1440P
Case Fractal Design Define S2
Audio Device(s) Corsair Virtuoso Pro
Power Supply 850W Seasonic Platinum
Mouse Razer Viper V2 Pro @ 2k Hz
Keyboard Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches
Software Windows 11 Pro
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
26,259 (4.64/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
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

  • ftp.zip
    7.8 KB · Views: 303
Last edited:
Joined
Feb 11, 2008
Messages
607 (0.10/day)
Location
Omaha, Nebraska, USA
System Name Built By Me
Processor Intel Core i9 9900K @ 5.1 GHz
Motherboard Gigabyte Z390 Aorus Ultra
Cooling Custom Water Cooling - CPU Only
Memory 32GB (2 x 16) GSkill Ripjaws V DDR4
Video Card(s) RTX 4080 - ASUS ROG Strix 16GB OC - P Mode
Storage 1TB Samsung 970 Evo NVMe
Display(s) Alienware AW2723DF @ 280 Hz @ 1440P
Case Fractal Design Define S2
Audio Device(s) Corsair Virtuoso Pro
Power Supply 850W Seasonic Platinum
Mouse Razer Viper V2 Pro @ 2k Hz
Keyboard Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches
Software Windows 11 Pro
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.
 

japrtorres

New Member
Joined
Feb 18, 2014
Messages
2 (0.00/day)
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
607 (0.10/day)
Location
Omaha, Nebraska, USA
System Name Built By Me
Processor Intel Core i9 9900K @ 5.1 GHz
Motherboard Gigabyte Z390 Aorus Ultra
Cooling Custom Water Cooling - CPU Only
Memory 32GB (2 x 16) GSkill Ripjaws V DDR4
Video Card(s) RTX 4080 - ASUS ROG Strix 16GB OC - P Mode
Storage 1TB Samsung 970 Evo NVMe
Display(s) Alienware AW2723DF @ 280 Hz @ 1440P
Case Fractal Design Define S2
Audio Device(s) Corsair Virtuoso Pro
Power Supply 850W Seasonic Platinum
Mouse Razer Viper V2 Pro @ 2k Hz
Keyboard Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches
Software Windows 11 Pro
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.
 

japrtorres

New Member
Joined
Feb 18, 2014
Messages
2 (0.00/day)
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
607 (0.10/day)
Location
Omaha, Nebraska, USA
System Name Built By Me
Processor Intel Core i9 9900K @ 5.1 GHz
Motherboard Gigabyte Z390 Aorus Ultra
Cooling Custom Water Cooling - CPU Only
Memory 32GB (2 x 16) GSkill Ripjaws V DDR4
Video Card(s) RTX 4080 - ASUS ROG Strix 16GB OC - P Mode
Storage 1TB Samsung 970 Evo NVMe
Display(s) Alienware AW2723DF @ 280 Hz @ 1440P
Case Fractal Design Define S2
Audio Device(s) Corsair Virtuoso Pro
Power Supply 850W Seasonic Platinum
Mouse Razer Viper V2 Pro @ 2k Hz
Keyboard Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches
Software Windows 11 Pro
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.
 
Top