用Web Services服务实现文件上传

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 nmlvjun 的 blog

  建立一个web services服务,
public string uploadfile(byte[] fs,string filename)
  {
   try
   {
    ///定义并实例化一个内存流,以存放提交上来的字节数组。
    memorystream m = new memorystream(fs);
    ///定义实际文件对象,保存上载的文件。
    filestream f = new filestream(server.mappath("") + "\\"
     + filename, filemode.create);
    ///把内内存里的数据写入物理文件
    m.writeto(f);
    m.close();
    f.close();
    f = null;
    m = null;
    return "文件已经上传成功。";
   }
   catch(exception ex)
   {
    return ex.message;
   }
  }

本文关键:用Web Services服务实现文件上传
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top