Example #1
0
    private void Save(string fileName, Stream stream)
    {
        MyProject02.ServiceReference1.UploadClient      client  = new MyProject02.ServiceReference1.UploadClient();
        MyProject02.ServiceReference1.FileUploadMessage message = new MyProject02.ServiceReference1.FileUploadMessage();
        message.FileName          = fileName;
        message.SavePath          = "/userImages/"; //@"D:\kkk\";
        message.FileData          = stream;
        message.FileData.Position = 0;              //必须将Position属性置为0,否则服务端接受后不能保存

        MyProject02.ServiceReference1.IUpload channel = client.ChannelFactory.CreateChannel();

        MyProject02.ServiceReference1.UploadResultMessage resultMessage = new MyProject02.ServiceReference1.UploadResultMessage();
        resultMessage = channel.UploadFile(message);

        //if (resultMessage.UploadResult == "1")
        //{
        //    InText.Alert("上传成功!");
        //}
    }
Example #2
0
        //上传按钮
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            //http://localhost:5750/Upload.svc

            ServiceReference1.UploadClient      client  = new MyProject02.ServiceReference1.UploadClient();
            ServiceReference1.FileUploadMessage message = new ServiceReference1.FileUploadMessage();
            message.FileName = FileUpload1.FileName;
            message.SavePath = @"D:\kkk\";
            message.FileData = FileUpload1.FileContent;

            ServiceReference1.IUpload channel = client.ChannelFactory.CreateChannel();

            ServiceReference1.UploadResultMessage resultMessage = new MyProject02.ServiceReference1.UploadResultMessage();
            resultMessage = channel.UploadFile(message);

            if (resultMessage.UploadResult == "1")
            {
                InText.Alert("上传成功!");
            }
        }