//Sending Message With Attachment public void sendMessageWithAttachment() { UIImageView imageview = new UIImageView(); imageview.Image = UIImage.FromBundle("test.png"); NSData imgData = imageview.Image.AsJPEG(); NSError err = null; var documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string sTempPath = "Demand.png"; string jpgFilename = System.IO.Path.Combine(documentsDirectory, sTempPath); bool b = imgData.Save(jpgFilename, false, out err); ALMessageServiceWrapper messaageService = new ALMessageServiceWrapper(); ALMessage messageObject = messaageService.CreateMessageEntityOfContentType(1, "119933", "PhotoTAG :"); messaageService.SendMessageWithAttachment(messageObject, jpgFilename, this, 1); }
/// <summary> /// 打包下载 /// </summary> /// <param name="packFolderPath">需要打包的文件夹所在路径</param> /// <param name="fileNames">需要打包的文件集合(文件名)</param> /// <param name="zipFileName">打包后显示的文件名</param> public static void FilePackDownload(string packFolderPath, List <string> fileNames, string zipFileName) { using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(System.Text.Encoding.Default))//解决中文乱码问题 { HttpContext httpContext = HttpContext.Current; httpContext.Response.Clear(); httpContext.Response.ContentType = "application/zip"; //兼容火狐和IE11的浏览器下载 string packFileName = ""; if (httpContext.Request.Headers["USER-AGENT"].IndexOf("MSIE") < 0 && httpContext.Request.Headers["USER-AGENT"].IndexOf("like Gecko") < 0) { packFileName = "=?UTF-8?B?" + ALEncrypt.Base64EnCode(zipFileName) + "?="; } else { packFileName = HttpUtility.UrlEncode(zipFileName, Encoding.UTF8); } httpContext.Response.AddHeader("content-disposition", "filename=" + packFileName); zip.AddDirectory(packFolderPath); foreach (string item in fileNames) { try { zip.AddFile(item); } catch (Exception err) { ALMessage.RegMsg("打包下载失败,具体原因:" + err.Message); } } zip.Save(httpContext.Response.OutputStream); } }