Closed n0ix closed 7 years ago
Hi,
I think you are probably using it right, but it's hard to tell, since the creation of FtpClient
is missing from your source code and the Retr()
is drowned in a lot of other lines (written in VB... Dude, it's been 21st century for a while now, VB should be forgotten).
Also you don't describe the problem, except "it doesn't work".
So a working sample here, assuming:
ftpUri
is pointing to a server, for example ftpUri = new Uri("ftp://myhost")
ftpCredential
is a valid credential such as ftpCredential = new NetworkCredential("account", "password")
ftpFilePath
points to a valid file, such as ftpFilePath = "/myfile"
using (var ftpClient = new FtpClient(ftpUri, ftpCredential)
{
using (var r = ftpClient.Retr(ftpFilePath))
{
// now you have a valid stream that you can read
}
}
This probably won't help you much, so if not, be more specific.
Hi picrap,
i just tested it again with a new Test Solution and another FTP Server just to be sure.
This is the Full error i get (FTP Stream IO Error):
InnerException = {"Connection error. Code=426 ('Failure writing network stream.')"}
bei ArxOne.Ftp.IO.FtpPassiveStream.Process[TResult](Func`1 func) in E:\programming\VB\Git Projekte\SFDL.NET\SFDL.FTP\ArxOne.Ftp\IO\FtpPassiveStream.cs:Zeile 174.
bei ArxOne.Ftp.IO.FtpPassiveStream.Process(Action action) in E:\programming\VB\Git Projekte\SFDL.NET\SFDL.FTP\ArxOne.Ftp\IO\FtpPassiveStream.cs:Zeile 149.
bei ArxOne.Ftp.IO.FtpPassiveStream.Release(Boolean expectEndReply) in E:\programming\VB\Git Projekte\SFDL.NET\SFDL.FTP\ArxOne.Ftp\IO\FtpPassiveStream.cs:Zeile 125.
bei ArxOne.Ftp.IO.FtpPassiveStream.Dispose(Boolean disposing) in E:\programming\VB\Git Projekte\SFDL.NET\SFDL.FTP\ArxOne.Ftp\IO\FtpPassiveStream.cs:Zeile 96.
bei System.IO.Stream.Close()
bei System.IO.Stream.Dispose()
bei DownloadTest.Module1.Main() in E:\programming\VB\Git Projekte\SFDL.NET\SFDL.NET 3\DownloadTest\Module1.vb:Zeile 103.
I also attachted my Test Solution. If you don't like VB.Net - just convert it into C#
An please i don't want a discussion if C# or VB.NET better - thanks.
//EDIT:
I think the Problem is that .Length and .Position in the _ftpstream Object is not available. But i need this Value to calc the Download Progress / Download Speed. When i try to Access these Values the error i posted above is thrown. So the Main Question is: Why are these Values not Present? The should be, because its a simple IO.Stream ?
That's right! The Position
and Length
properties are not available, since the Stream
has its CanSeek
property to false
, so this is absolutely normal.
Working around the problem is simple:
Stream.Read()
List
or Mlsd
So this is normal you get an exception, however the exception itself is not.
Hi again,
thanks for the Workaround and looking into this issuse!
Exceptions are now NotSupportedException
when the operation is not permitted, as stated in Stream
documentation.
I think we can close the issue, can't we?
Hi, i try to use your FTP Library, but i don't get it managed to Download a File. Maybe you can provide me a simple Example or you may have a tip whats wrong with my Code?
Here is my Code
Thanks in andvance.