Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai i am uploading the file in FTP server at that time i am geting the erroe:The requested URI is invalid for this FTP command.Below is my code Please help me for this issue


VB
Dim sourcefilepath As String = AttachUpload.FileName
                    Dim ftpurl As [String] = "ftp://buson.in/"
                    Dim ftpusername As [String] = "busonsupport"
                    Dim ftppassword As [String] = "busonsupport"
                    Dim filename As String = Path.GetFileName(AttachUpload.FileName)
                    Dim ftpfullpath As String = ftpurl
                    Dim ftp As FtpWebRequest = DirectCast(FtpWebRequest.Create(ftpfullpath), FtpWebRequest)
                    ftp.Credentials = New NetworkCredential(ftpusername, ftppassword)

                    ftp.KeepAlive = True
                    ftp.UseBinary = True
                    ftp.Method = WebRequestMethods.Ftp.UploadFile

                    Dim fs As Stream = AttachUpload.PostedFile.InputStream
                    Dim buffer As Byte() = New Byte(fs.Length - 1) {}
                    fs.Read(buffer, 0, buffer.Length)
                    fs.Close()

                    Dim ftpstream As Stream = ftp.GetRequestStream()'Hear Only i got error
                    ftpstream.Write(buffer, 0, buffer.Length)
                    ftpstream.Close()
Posted
Comments
_Damian S_ 6-Aug-13 2:43am    
Please tell me they aren't your real ftp details (site, user, password)? If they are, I suggest you remove them and replace them with made up data. Also, having your email address as your username is likely to result in an increased amount of spam.

1 solution

What version of .NET Framework are you targeting? I'm pretty sure the ftp uri is only supported from .NET 4 onwards.
 
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