SharePoint Attachement操作代码

SharePoint Attachement操作代码

SharePoint Attachement操作代码

下载文件

SharePoint Attachement操作代码

如果下载其它类别的文件:

SharePoint Attachement操作代码SharePoint Attachement操作代码
 SPSecurity.RunWithElevatedPrivileges(].ToString();
                            switch (casestring)
                            {
                                case "txt":
                                    strContentType = "text/plain";
                                    break;
                                case "htm":
                                    strContentType = "text/html";
                                    break;
                                case "html":
                                    strContentType = "text/html";
                                    break;
                                case "rtf":
                                    strContentType = "text/richtext";
                                    break;
                                case "jpg":
                                    strContentType = "image/jpeg";
                                    break;

case "jpeg":
                                    strContentType = "image/jpeg";
                                    break;
                                case "gif":
                                    strContentType = "image/gif";
                                    break;
                                case "bmp":
                                    strContentType = "image/bmp";
                                    break;
                                case "mpg":
                                    strContentType = "video/mpeg";
                                    break;
                                case "mpeg":
                                    strContentType = "video/mpeg";
                                    break;
                                case "avi":
                                    strContentType = "video/avi";
                                    break;
                                case "pdf":
                                    strContentType = "application/pdf";
                                    break;
                                case "doc":
                                    strContentType = "application/msword";
                                    break;
                                case "dot":
                                    strContentType = "application/msword";
                                    break;
                                case "csv":
                                    strContentType = "application/vnd.msexcel";
                                    break;
                                case ".xls":
                                    strContentType = "application/vnd.msexcel";
                                    break;
                                case ".xlt":
                                    strContentType = "application/vnd.msexcel";
                                    break;
                                default:
                                    strContentType = "application/octet-stream";
                                    break;
                            }
                            Response.ClearContent();
                            Response.ClearHeaders();
                            Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename.ToString());
                            Response.ContentType = strContentType;

//Check that the client is connected and has not closed the connection after the request
                            if (Response.IsClientConnected)
                            {
                                Response.BinaryWrite(obj);
                            }
                            Response.Flush();
                            Response.Close();
                        }
                    }
                });
            }
            catch (Exception ex)
            {

}

上一篇:[Sequence Alignment Methods] Dynamic time warping (DTW)


下一篇:【题解】CF1585C Minimize Distance