public string PostDeleteFile([FromBody] FileApiModel parameter)
        {
            try
            {
                var data = new
                {
                    Status = ResponseStatus.Success,
                    Msg    = "附件删除成功。",
                    Data   = ""
                };

                if (!string.IsNullOrEmpty(parameter.BUrlPath))
                {
                    var path = System.Web.Hosting.HostingEnvironment.MapPath("~" + parameter.BUrlPath);

                    //删除文件
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                    else
                    {
                        data = new
                        {
                            Status = ResponseStatus.Error,
                            Msg    = "附件不存在。",
                            Data   = ""
                        };
                    }
                }
                else
                {
                    data = new
                    {
                        Status = ResponseStatus.Error,
                        Msg    = "附件不存在。",
                        Data   = ""
                    };
                }
                return(DataConverterHelper.SerializeObject(data));
            }
            catch (Exception ex)
            {
                return(DCHelper.ErrorMessage(ex.Message));
            }
        }
Beispiel #2
0
 internal ApiResultFileApiModel(FileApiModel data)
 {
     Data = data;
 }