WebRequestMethods.Ftp.ListDirectory doesnt display all files

pursuitofgold

New member
Joined
Jan 21, 2009
Messages
1
Programming Experience
Beginner
Hey, I am having trouble listing all files in a directory with WebRequestMethods.Ftp.ListDirectory. Heres my code


Dim ftpWebReq As FtpWebRequest = FtpWebRequest.Create("ftp://website.com//log/")

ftpWebReq.Method = WebRequestMethods.Ftp.ListDirectory

ftpWebReq.Credentials = New NetworkCredential("user", "pass")






Dim ftpWebResp As FtpWebResponse = CType(ftpWebReq.GetResponse(), FtpWebResponse)

Dim streamer As Stream = ftpWebResp.GetResponseStream()




Dim reader As New StreamReader(streamer)

Dim sw As StreamWriter = New StreamWriter("c://test//test.txt")

sw.Write(reader.ReadToEnd)

streamer.Close()

sw.Close()




and theres two files in the directory, "boot.log" and "access_log_sep_08.log" but when I run this program only "boot.log" shows up. And when I try to directly Download these two files, I can download "boot.log" fine but get :
The remote server returned an error: (550) File unavailable (e.g., file not found, no access). when trying to download the other. I can view all of them fine in filezilla etc and permissions are all the same... Can someone help? thanks.
 
This code works fine on my end.

VB.NET:
		Dim fwr As Net.FtpWebRequest = Net.FtpWebRequest.Create("ftp://local.ftp.server")
		fwr.Credentials = New NetworkCredential("user", "pass")
		fwr.Method = WebRequestMethods.Ftp.ListDirectory

		Using sr As New StreamReader(fwr.GetResponse().GetResponseStream())
			Using sw As New StreamWriter("C:\Temp\FtpDir.txt", False)
				sw.Write(sr.ReadToEnd())
			End Using
		End Using

		fwr = Nothing

What happens when you try and list the files using ftp.exe?

Start --> Run --> Cmd

Ftp
Open ftp.server.address
Username
Password
cd dirname
dir
 
Back
Top