开发者

Uploading files recursively with WebClient

I am writing a .NET application in C# that needs to upload some files onto a server using FTP. I am looking at the UploadFileAsync method provided by he WebClient class:

http://msdn.microsoft.com/en-us/library/ms144232(v=vs.80).aspx

What I am curious about is what happens if I tell it to upload a directory?

In my dreams it would recursively upload the directory and all of its contents.... Does anybody have any experience with this, or know any way I could get all the files up there without having to go through and manually c开发者_如何学JAVAreate the sub directories and upload the files one by one?


It will not work like that. If you pass a directory, you'll get an error. There's no shortcut of the kind you seek, unfortunately.


Yuo can get all the files of any level of a folder easily by Directory.GetFiles(), then loop through the files one by one and upload it.


Under UltraVNC, when I upload a directory, it creates a zip of the directory, uploads it as a file, and unzips it there. You might want to call a script that unzips the file.

I just searched on stackoverflow, and I think there are better solutions.

https://stackoverflow.com/questions/2252000/upload-a-folder-by-ftp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜