惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
WordPress大学
WordPress大学
U
Unit 42
I
InfoQ
A
About on SuperTechFans
宝玉的分享
宝玉的分享
J
Java Code Geeks
博客园 - 司徒正美
爱范儿
爱范儿
Engineering at Meta
Engineering at Meta
G
Google Developers Blog
人人都是产品经理
人人都是产品经理
小众软件
小众软件
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI
腾讯CDC
Recent Announcements
Recent Announcements

博客园 - vcool

HI C#解压RAR压缩文件 C# 调用outlook 发送邮件 或添加附件发送 - vcool vb调用webservice 报表服务器无法打开与报表服务器数据库的连接 在WEB中实现打印分页 微软的面试题及答案-超变态但是很经典 AutoResetEvent和ManualResetEvent 篮球的各个位置的职能!!! WF 与 WCF 集成 六步使用ICallbackEventHandler实现无刷新回调 ArcGIS Server .Net Web ADF体系结构 ASP.NET中处理读写XML小结 我们期待自己成为一个优秀的软件模型设计者 XML实现异构数据库间转换的实现与分析 异构数据库 第九交响曲 利用ArcGIS Engine、VS .NET和Windows控件开发GIS应用 如何创建强命名程序集
C# 操作TIF
vcool · 2008-05-14 · via 博客园 - vcool

ASP.net 1.1 smtp发邮件

Sent email by System.Web.Mail.MailMessage in c#
-handiz@hotmail.com
-----------------------------------------------------
public void SendMail(string recp, string title, string msg)
{
//define Mail message

System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();

mail.To = recp;
mail.From = System.Configuration.ConfigurationSettings.AppSettings["MailSender"];
mail.Subject = title;
mail.Body = msg;

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","username"); //your smtp username
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","password"); //your smtp password

System.Web.Mail.SmtpMail.SmtpServer = "smtp.mail"; //your smtp server address
System.Web.Mail.SmtpMail.Send(mail);
}

ASP.net 2.0 smtp发邮件:

Date:2006-11-08, Title:(DotNet) How to sent email from C#2.0


(DotNet) How to sent email from C#2.0 

handiz@hotmail.com

-------------------
static public void SendMail(string recp, string title, string msg)
{
//sender
string strFrom = System.Configuration.ConfigurationManager.AppSettings["MailSender"];

//smtp server password
string strPass = System.Configuration.ConfigurationManager.AppSettings["MailPassword"];

//mail object
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(strFrom,recp);
mail.Subject = title;
mail.Body = msg;
mail.IsBodyHtml = true;
mail.BodyEncoding = System.Text.Encoding.UTF8;

System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();

//smtp serveraddress
smtpClient.Host = System.Configuration.ConfigurationManager.AppSettings["MailSmtp"];
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential(strFrom, strPass);
//smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtpClient.Send(mail);
}

合并/分割 TIF 图片:

Title:Generate multipage TIF and split multipage TIF in C#


Generate multipage TIF and split multipage TIF in C#

MSN: handiz@hotmail.com
Email: handiz@gmail.com
----------------
Using the TifPrint.dll
(download at: http://www.diaries.cn/myworks/MSDotNet/Class/TifPrint/BIN/tifprint.zip)

//split the multiple page TIF file into single file
SplitTif(strFilename, strTargetFolder)

//Combine the Files(can be jpg, bmp, tif, png, gif) into one multipage Tif file
CombineTif(string[] InputFilenames, string OutputFilename)

----------------
/// <summary>
/// Combine some file into 1 tif multipage file
/// if black and write image, we use CCITT4 compression
/// else we use the LZW compression
/// </summary>
/// <param name="InputFilenames">the files to be combined, canbe (bmp, jpg, gif, png, tif)</param>
/// <param name="OutputFilename">the output filename</param>
public static void CombineTif(string[] InputFilenames, string OutputFilename)
{
//get ImageCodecInfo, generate tif format
ImageCodecInfo info = null;
foreach (ImageCodecInfo ice in ImageCodecInfo.GetImageEncoders())
{
if (ice.MimeType == "image/tiff")
{
info = ice;
break;
}
}

/*
* define the encoderparameter,
* when the 1st page, will be EncoderValue.MultiFrame.
* when the other pages, will be EncoderValue.FrameDimensionPage.
* when all pages saved, will be the EncoderValue.Flush.
*/

EncoderParameters ep = new EncoderParameters(2);

/*
* when the 1st file, 1st frame, will be true.
* from the 1st file, 2nd frame, will be false.
*/
bool b11 = true;

Image img =null;

//create a image instance from the 1st image
for (int nLoopfile = 0; nLoopfile < InputFilenames.Length; nLoopfile ++)
{
//get image from src file
Image img_src = Image.FromFile(InputFilenames[nLoopfile]);

Guid guid = img_src.FrameDimensionsList[0];
System.Drawing.Imaging.FrameDimension dimension = new
System.Drawing.Imaging.FrameDimension(guid);

//get the frames from src file
for (int nLoopFrame =0; nLoopFrame < img_src.GetFrameCount(dimension); nLoopFrame ++)
{
img_src.SelectActiveFrame(dimension, nLoopFrame);

/*
* if black and write image, we use CCITT4 compression
* else we use the LZW compression
*/
if (img_src.PixelFormat == PixelFormat.Format1bppIndexed)
{
ep.Param[0] = new EncoderParameter(Encoder.Compression, Convert.ToInt32(EncoderValue.CompressionCCITT4));
}
else
{
ep.Param[0] = new EncoderParameter(Encoder.Compression, Convert.ToInt32(EncoderValue.CompressionLZW));
}

if (b11)
{
//1st file, 1st frame, create the master image
img = img_src;

ep.Param[1] = new EncoderParameter(Encoder.SaveFlag, Convert.ToInt32(EncoderValue.MultiFrame));
img.Save(OutputFilename, info, ep);

b11 = false;
continue;
}

ep.Param[1] = new EncoderParameter(Encoder.SaveFlag, Convert.ToInt32(EncoderValue.FrameDimensionPage));
img.SaveAdd(img_src, ep);
}
}
ep.Param[1] = new EncoderParameter(Encoder.SaveFlag, Convert.ToInt32(EncoderValue.Flush));
img.SaveAdd(ep);
}


====================

Title:(DotNet) How to split multiple page TIF to single file in c#


(DotNet) How to split multiple page TIF to single file in c#

handiz@hotmail.com
---------------------------------------------------------
//This function will split a TIF file into sigle file, and put them
//into strTargerFolder.
public static void SplitTIF(string strFilename, string strTargetFolder)
{
Image img = Image.FromFile(strFilename);
Guid guid = img.FrameDimensionsList[0];
System.Drawing.Imaging.FrameDimension dimension = new
System.Drawing.Imaging.FrameDimension(guid);
int nTotFrame = img.GetFrameCount(dimension);

//save all frame
int nLoop =0;
for (nLoop = 0; nLoop<nTotFrame; nLoop++)
{
img.SelectActiveFrame(dimension, nLoop);
img.Save(strTargetFolder + "\\"+nLoop.ToString() + ".tif",
System.Drawing.Imaging.ImageFormat.Tiff);
}
}

打印 TIF 图片:
Title:4 steps to Print Tif in c# 

4 steps to Print Tif in c#

handiz@hotmail.com
----------------
Using the TifPrint.dll
(download at: http://www.diaries.cn/myworks/MSDotNet/Class/TifPrint/BIN/TifPrint.dll)

//1. create instance of TifPrint
TifPrint tp = new TifPrint();

//2. add tif files to printing list:
tp.AddFile(@"c:\1.tif");
tp.AddFile(@"c:\2.tif");
...

//3. show printing dialog or not
tp.ShowDialog = true;

//4. Print
tp.Print();

Other functions:
ClearFile() - remove all files from printing list
GetPageCount() - return the total page number of printing list
SplitTif(strFilename, strTargetFolder) - split the multiple page TIF file into single file

 
C#将网页保存为mht 文件
            

1. 增加 COM Reference
Microsoft CDO for Windows 2000 Library (C:\WINDOWS\System32\cdosys.dll)

2. 程序:

            CDO.Message msg = new CDO.MessageClass();
            CDO.Configuration cfg = new CDO.ConfigurationClass();
           
            msg.Configuration = cfg;
            msg.CreateMHTMLBody("http://www.sina.com.cn", CDO.CdoMHTMLFlags.cdoSuppressAll, "", "");

            msg.GetStream().SaveToFile("c:\\a.mht", ADODB.SaveOptionsEnum.adSaveCreateOverWrite);