lu
2025-06-02 a80c1ccadaa85132c7ac26474e7aab3da7706cbc
DevApp/Gs.DevApp/UserControl/UCUpFile.cs
@@ -1,16 +1,8 @@
using DevExpress.Utils.DirectXPaint;
using DevExpress.XtraEditors;
using Gs.DevApp.ToolBox;
using Gs.DevApp.ToolBox;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -25,7 +17,19 @@
            btnUpSelect.Click += BtnUpSelect_Click;
            btnUp.Click += BtnUp_Click;
        }
        /// <summary>
        /// 父亲guid
        /// </summary>
        public string parentGuid
        {
            get;
            set;
        }
        /// <summary>
        /// 图片分组,比如login,logo等分组
        /// </summary>
        public string parentGroup
        {
            get;
            set;
@@ -49,7 +53,7 @@
            // 设置初始目录
            openFileDialog.InitialDirectory = "c:\\";
            // 设置文件过滤选项,如:"文本文件 (*.txt)|*.txt|所有文件 (*.*)|*.*"
            openFileDialog.Filter = "文本文件 (*.txt)|*.txt|所有文件 (*.*)|*.*";
            openFileDialog.Filter = "所有文件 (*.*)|*.*";
            // 设置标题
            openFileDialog.Title = "选择文件";
            // 显示对话框
@@ -86,7 +90,6 @@
        private async Task UploadFileAsync(string url, string filePath)
        {
            UcLoading _loading = new UcLoading();
            string _parentGuid = parentGuid;
            using (var httpClient = new HttpClient())
                try
@@ -98,7 +101,7 @@
                        using (var fs = File.OpenRead(filePath))
                        using (var streamContent = new StreamContent(fs))
                        {
                            form.Add(streamContent, "file", _parentGuid + "~" + Path.GetFileName(filePath));
                            form.Add(streamContent, "file", _parentGuid + "~" + Path.GetFileName(filePath) + "~" + parentGroup);
                            var response = await httpClient.PostAsync(url, form);
                            var responseString =
                                await response.Content.ReadAsStringAsync();
@@ -110,9 +113,7 @@
                catch (Exception ex)
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message);
                }
            _loading.Close();
        }
        #endregion