国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

利用SOAP(Webservice)上傳文件

2024-07-21 02:21:18
字體:
來源:轉載
供稿:網友
本文系鼎鼎原創,如轉載,請注明出處: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;
客戶端直接用調用,把數據流作參數傳上來就完了。



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 遂溪县| 桂平市| 宁强县| 武汉市| 西盟| 孟州市| 鄂伦春自治旗| 菏泽市| 上饶县| 屯门区| 星子县| 金川县| 民和| 兴宁市| 洛南县| 石林| 张家港市| 闸北区| 隆尧县| 尉犁县| 昆明市| 阳谷县| 鲜城| 岳池县| 西盟| 榆社县| 平阴县| 新田县| 忻城县| 黔东| 满洲里市| 潮州市| 汨罗市| 台东市| 彭阳县| 弥勒县| 洛浦县| 古交市| 永泰县| 常德市| 栖霞市|