Click here to Skip to main content
15,918,676 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i have files stored at azure blob. Now i want to transfer file directly form blob to ftp server.

i have tried this.
C#
string ftpfullpath = @"ftp://myftp.com/Test.xml";
                
                
                FtpWebRequest ftp = WebRequest.Create(ftpfullpath) as FtpWebRequest;
                if (ftp != null)
                {
                    ftp.Credentials = new NetworkCredential("uname", "pass");

                    ftp.KeepAlive = false;
                    ftp.UseBinary = true;
                    ftp.Method = WebRequestMethods.Ftp.UploadFile;
                }

                FileStream fs = File.OpenRead(blobfilePath.Replace("https","http"));
                byte[] buffer = new byte[fs.Length];
                fs.Read(buffer, 0, buffer.Length);
                fs.Close();

                Stream ftpstream = ftp.GetRequestStream();
                ftpstream.Write(buffer, 0, buffer.Length);
                ftpstream.Close();

But am am getting an error 'URI formats are not supported'.

how can i achieve this..

Thanks in advance.
Posted
Updated 10-Feb-13 21:27pm
v5
Comments
Sergey Alexandrovich Kryukov 11-Feb-13 1:52am    
Where is FTP here? Only HTTP...
—SA
Sergey Alexandrovich Kryukov 11-Feb-13 2:34am    
It does not look like a valid address...
—SA
Sergey Alexandrovich Kryukov 11-Feb-13 3:08am    
remove blank space before "ftp"...
Sergey Alexandrovich Kryukov 11-Feb-13 4:40am    
Oh... why do you replace HTTP with HTTPS what is the actual protocol? This should be a problem...
—SA
Guirec 11-Feb-13 5:47am    
it is you File.OpenRead(blobfilePath.Replace("https","http")); which does not support URI formats.
To open your azure file you should do WebRequest.Create as well if it is distant or File.OpenRead but then with a path not a url.

1 solution

you're most welcome, Just answering here so that it's not appearing in unswanred questions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900