Click here to Skip to main content
15,789,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is my code which is thronging and error of the given is path is not supported,
here str holds my ftp file path.


salesid = cmbclient.SelectedValue
createdon = Today.Date.ToShortDateString
ReDim docimage(ob.ConvertImageToByteArray(str).Length)
docimage = ob.ConvertImageToByteArray(str)
createdby = UserName
filename = ListBox1.SelectedItem
srv.SaveInvoiceImage(salesid:=salesid, CB:=docimage, invoiceimage:=filename, createdon:=createdon, createdby:=createdby)
MsgBox("Image Approval Succedded", MsgBoxStyle.Information)


Public Function ConvertImageToByteArray(ByVal str As String) As Byte()
Dim fs As FileStream = New FileStream(str, FileMode.Open, FileAccess.Read)//error through here
Dim length As Integer = Convert.ToInt32(fs.Length)
Dim data() As Byte = Nothing
ReDim data(length)
fs.Read(data, 0, data.Length)
fs.Close()
Return data

What I have tried:

I have tried this

salesid = cmbclient.SelectedValue
createdon = Today.Date.ToShortDateString
ReDim docimage(ob.ConvertImageToByteArray(str).Length)
docimage = ob.ConvertImageToByteArray(str)
createdby = UserName
filename = ListBox1.SelectedItem
srv.SaveInvoiceImage(salesid:=salesid, CB:=docimage, invoiceimage:=filename, createdon:=createdon, createdby:=createdby)
MsgBox("Image Approval Succedded", MsgBoxStyle.Information)


Public Function ConvertImageToByteArray(ByVal str As String) As Byte()
Dim fs As FileStream = New FileStream(str, FileMode.Open, FileAccess.Read)error through here
Dim length As Integer = Convert.ToInt32(fs.Length)
Dim data() As Byte = Nothing
ReDim data(length)
fs.Read(data, 0, data.Length)
fs.Close()
Return data
Posted
Updated 22-Apr-16 0:18am
Comments
Garth J Lancaster 22-Apr-16 4:53am    
what is the value of 'str' for a typical case ?
Anjani Rawat 22-Apr-16 4:57am    
value of str is like that:

ftp://ftpurl//xyz/abc/wer/image.jpg
Garth J Lancaster 22-Apr-16 6:11am    
yeah - well, you cant read that location with a FileStream - see phil.o's solution of what you may be able to use instead

1 solution

I don't think you can use a FileStream directly with a FTP address.
You may have to use a FtpWebRequest instead:
FtpWebRequest Class[^]
How to: Download Files with FTP[^]
 
Share this answer
 
Comments
Anjani Rawat 22-Apr-16 6:44am    
i have tried with ftpweprequest but did not get solution , will you guide me how ftpwebrequest can read and acess file
phil.o 22-Apr-16 6:50am    
I could not be better than what is indicated in the second link. You will have to follow the tutorial, and describe specific issue you are encountering in the process.

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