You need to implement FTP client - in pre dot net there was a control that made life easy.
People at MS decided that it was too easy so they didn't include one in the framework so you have write it yourself...
There was a very nice class publish by MS for some reason link is no longer available.
I found another one so give it the try: FTP Client Technology Sample (directly from MSDN).
The help topic for the WebClient.UploadFile method specifically demonstrates that you need to specify the file name on the FTP server, which was the issue in your other thread. If a method or property doesn't work the way you expect then the first thing you should do ALWAYS is read its help topic. More often than not it you can solve your problem yourself very quickly.
[QUOTE=jmcilhinney]It's still easy in post-VB6...QUOTE]
Poooolease, dodn't even start that nuisance - all I can tell you is that someone at MS made a big mistake not to include FTP wrapper control. FTP is old but is getting more and more use today and especially in the digital era - files are much much bigger then when FTP was first introduced.
You haven't imported the System.Net namespace so you can't use the name WebClient without qualifying it with the namespace. Add "Net." before "WebClient" and it will work.
As for the code you just posted, I SPECIFICALLY stated in my last post that you MUST specify the file name on the FTP server. You aren't doing that so it's not going to work.
Finally, you don't have to use a Using block but it is the recommended way to do things. When you create a WebClient object it ties up system resources. For that reason you should dispose it once you're done with it, to release those resources. You can declare it normally and dispose it explicitly:
VB Code:
Dim wc As Net.WebClient
'...
wc.Dispose()
but it is recommended when using disposable objects in a local block that you employ a Using block, which implicitly disposes the object even if an exception is thrown.
It's still easy in post-VB6...QUOTE]
Poooolease, dodn't even start that nuisance - all I can tell you is that someone at MS made a big mistake not to include FTP wrapper control. FTP is old but is getting more and more use today and especially in the digital era - files are much much bigger then when FTP was first introduced.
I read an implication that something was easy in VB6 and is now hard in VB.NET. I've read implications like that before. I've made implications myself in the reverse, which may or may not have been true. If you want to say that something requires a certain amount of work in VB.NET then you obviously have the right to say it. What bugs me is the digs at VB.NET and the unnecessary implication that things were better back in the pre-.NET days. If you can upload a file to an FTP site in four lines of code then I don't see an issue. If you want to create your own FTP client then you have the fine-grained control to do so with the FtpWebRequest and FtpWebResponse classes in exactly the way you want, but that sort of control is often not needed.
RhinoBull, you may think that I simply jump to the defense of VB.NET as a knee-jerk reaction, and maybe I do, at least in part. My issue is the number of posts that you've made in the VB.NET forum that imply or state that things were better in VB6. If someone is coding in VB.NET then whether or not there is a VB6 class that makes things easy is immaterial. To say that it is so serves no useful purpose that I can see other than to try to affirm some perceived superiority of VB6 over VB.NET. You have the right to your opinion and to post what you like, but what you actually said was that you need to implement your own FTP client in VB.NET rather than using the VB6 class that the operation easy. That's just plain untrue.
You know Jim, I've got very tired of your blatancy - if you like writing books be my guest but try not to reply to me with 10 pages of basically nothing.
When in the heck did mention VB6? I said "pre-dot-net" and "language is irrelevant" - point is that ftp controls were available in practically every language including VB6. Why was it dropped in .Net remains a mystery.
You need to implement FTP client - in pre dot net there was a control that made life easy.
People at MS decided that it was too easy so they didn't include one in the framework so you have write it yourself...
There was a very nice class publish by MS for some reason link is no longer available.
I found another one so give it the try: FTP Client Technology Sample (directly from MSDN).