private void btnUploadAvatar_Click(object sender, RoutedEventArgs e)
        {
            string avatar = _OpenFileDialog("选择头像", "jpg文件(*.jpg)|*.jpg");

            if (!string.IsNullOrEmpty(avatar))
            {
                using (FileStream fs = File.Open(avatar, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    try
                    {
                        WebApiClientHelper.DoStreamRequest(
                            GlobalData.GetResUri(string.Format("avatars/{0}", GlobalData.CurrentUserName)),
                            EnuHttpMethod.Put, fs);
                    }
                    catch (ClientException ex)
                    {
                        Commands.ShowPopupAlert.Execute(new ShowPopupAlertParam {
                            AlertMessage = ex.Message, AlertType = EnuPopupAlertType.Error
                        }, this);
                        return;
                    }
                }

                //设置头像(需要重新打开文件流并将它转为MemoryStream)
                using (FileStream fs = File.Open(avatar, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    if (fs.Length > 0)
                    {
                        byte[] memory = new byte[fs.Length];
                        fs.Read(memory, 0, (int)fs.Length);
                        SetAvatarImage(new MemoryStream(memory));
                    }
                }
            }
        }
        private void RetrieveMyAvatar()
        {
            Stream stm;

            try
            {
                stm = WebApiClientHelper.DoStreamRequest(GlobalData.GetResUri(string.Format("avatars/{0}", GlobalData.CurrentUserName)), EnuHttpMethod.Get);
            }
            catch (ClientException) //忽略获取失败的错误
            {
                return;
            }

            if (stm == null)
            {
                imgAvatar.Source = null;
                return;
            }

            SetAvatarImage(stm);
        }