当前位置: 首页 > 编程语言 > C#

WCFRestful服务文件上传,支持多平台共享

时间:2023-04-10 17:29:35 C#

WCFRestful服务文件上传,支持多平台谁能告诉我如何创建一个WCFRest服务,通过它我可以使用android,iphone和WP7上传文件到服务器。感谢您的帮助,我能够为多个平台创建文件上传wcfrest服务。publicvoidFileUpload(stringfileName,StreamfileStream){FileStreamfileToupload=newFileStream("c:\FileUpload\"+fileName,FileMode.Create);byte[]bytearray=newbyte[10000];intbytesRead,totalBytesRead=0;做{bytesRead=fileStream.Read(bytearray,0,bytearray.Length);totalBytesRead+=bytesRead;}while(bytesRead>0);fileToupload.Write(bytearray,0,bytearray.Length);fileToupload.C??lose();文件上传.Dispose();}[ServiceContract]publicinterfaceIImageUpload{[OperationContract][WebInvoke(Method="POST",UriTemplate="FileUpload/{fileName}")]voidFileUpload(stringfileName,StreamfileStream);Android可以使用,iphone和WP7访问任何Rest服务。一种选择是使用WCF或MVC将数据图像作为base64字符串创建RestPOST服务。以上就是C#学习教程:WCFRestful服务文件上传,支持多平台共享所有内容,如果对你有用,需要了解更多C#学习教程,希望大家多多关注——本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处: