duyongjia
2024-12-14 1bdb5689ddf1560a312de9413ce1c26e5163627d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
 
namespace PDA
{
    public class PDAOperate
    {
        public static WebResponseContent UploadApp(List<Microsoft.AspNetCore.Http.IFormFile> files)
        {
            try
            {
                if (files == null || files.Count == 0)
                    return new WebResponseContent { Status = true, Message = "请选择上传的文件" };
                Microsoft.AspNetCore.Http.IFormFile formFile = files[0];
                string dicPath = $"Upload/App/".MapPath();
                if (!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath);
                string path = $"{dicPath}WMS-PDA{DateTime.Now:yyyyMMddhhmmss}.apk";
                dicPath = $"{dicPath}WMS-PDA.apk";
                File.Move(dicPath, path);
 
                using (var stream = new FileStream(dicPath, FileMode.Create))
                {
                    formFile.CopyTo(stream);
                }
                return new WebResponseContent { Status = true, Message = "文件上传成功" };
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
    }
}