How to send a .ZIP file to Web Service using ASP.NET(C#) Is Impossible?
+1
A:
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.)
David
2010-08-16 12:34:23
Hımm thanks.I dont want to file with method argument.Is only way send with argument?
Murat
2010-08-16 12:42:49
@Murat: It depends on your web service setup. Does your service just expose web methods? If so then that's what the service _does_ is expect method arguments.
David
2010-08-16 12:46:51
+1
A:
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
Turnkey
2010-08-16 12:46:04