开发者

How to send a .ZIP file to Web Service

How to send a .ZIP file to Web Service 开发者_开发技巧using ASP.NET(C#) Is Impossible?


You can convert the file to a byte array and pass that array to the service:

var fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
var fileData = new byte[fs.Length];
fs.Read(fileData, 0, Convert.ToInt32(fs.Length));
fs.Close();

Just pass fileData to the web service as a method argument or however you would normally pass a value in your setup. (Personally I prefer request/response style service layers rather than webmethods, but to each his own.)


If the files might be large you probably want to use a chunking method to get them sent so you can provide feedback to your users:

CodeProject - Sending Files in Chunks with MTOM Web Services and .NET 2.0

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜