欢迎光临
我们一直在努力

利用SOAP(Webservice)上传文件-.NET教程,Web Service开发

建站超值云服务器,限时71元/月

本文系鼎鼎原创,如转载,请注明出处:http://blog.csdn.net/weisunding

[webmethod(description="上传并保存图片文件")]

public bool savefile(byte[] bindata,string filename){

bool success=false;

string savepath=system.configuration.configurationsettings.appsettings["uploaddirectory"];

if(savepath==null) savepath="photo";

if(savepath.indexof(":\\")<0) savepath=server.mappath(savepath);//不是绝对路径

if(!savepath.endswith("\\")) savepath += "\\";

if(!directory.exists(savepath)){

throw new exception("服务器端没有找到有效的保存路径!");

}

filestream filestream=null;

try{

filestream=new filestream(savepath + filename,filemode.create,fileaccess.write);

//write the file

filestream.write(bindata,0,bindata.length);

filestream.flush();//clear the buffer,write the data to the hard disk

success=true;

}catch(exception ex){

throw new exception(ex.message);

}finally{

filestream.close();

}

return success;

}

解决思路:编写webservice过程savefile(byte[] bindata,string filename0;

客户端直接用调用,把数据流作参数传上来就完了。

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 利用SOAP(Webservice)上传文件-.NET教程,Web Service开发
分享到: 更多 (0)

相关推荐

  • 暂无文章