zoukankan      html  css  js  c++  java
  • webservices传文件

    有两种方法,一种是把二进制对象转成base64码,返回字符串,应该是最简单的方法,另外一种就是返回二进制数组TByteArray
    服务器:
    function TFileSoap.getPic(out size:integer): TByteArray;
    var
    buf:TMemoryStream;
    begin
    try
        if not FileExists('c:\1.bmp') then
          raise Exception.Create('file not found.');

        buf:=TMemoryStream.create;
        buf.LoadFromFile('c:\1.bmp');
        size:=buf.Size;
        setlength(result,size);
        move(buf.Memory^,result[0],size);
    finally
        buf.free;
    end;
    end;
    客户端
    procedure TForm1.Button1Click(Sender: TObject);
    var
    size:integer;
    buf:TMemoryStream;
    ary:TByteArray;
    begin
    buf:=TMemoryStream.create;
    try
        ary:=GetIFileSoap.getPic(size);
        buf.SetSize(size);
        move(ary[0],buf.memory^,size);
        Image1.Picture.Bitmap.LoadFromStream(buf);
    finally
        buf.free;
    end;
    end;

  • 相关阅读:
    [HNOI2008]玩具装箱TOY
    UVA1185 Big Number
    01分数规划
    [HNOI2010]弹飞绵羊
    Mobius反演的套路
    MySQL日志
    MySQL事务、锁机制、查询缓存
    MySQL的索引
    MySQL的存储引擎
    HAProxy学习笔记
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2743197.html
Copyright © 2011-2022 走看看