测试类

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Messaging;
using System.Text.RegularExpressions;

namespace Console1
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			/*string mqName = "test";
			CreaetPrivateMessageQueue(mqName);
			
			SendMessage(mqName, "hello,world");
			
			ReceiveMessage(mqName);*/
			string fname = "aaa.png";
			Console.WriteLine (DateTime.Now.ToString("yyyyMMddhhmmss"));
			Console.WriteLine (fname.Substring(fname.LastIndexOf('.')));


			string aa = "<html><head>1</head></html><html><head>2</head><body></body></html><html><head>3</head></html>";
			Console.WriteLine (aa);
			Regex reg = new Regex(@"(<html>(.*?)</html>)?",RegexOptions.IgnoreCase);

			MatchCollection matchs = reg.Matches(aa);
			
			if(matchs.Count>0)
			{
				Console.WriteLine (matchs.Count);
				for (int i = 0; i < matchs.Count; i++) {
					Console.WriteLine (matchs[i].Groups[0].Value); 
				}
			}



			Console.ReadKey (true);

		}

		private static void CreaetPrivateMessageQueue(string mqName)
		{
			var path = CreateMessageQueuePath(mqName);
			
			if (!MessageQueue.Exists(path))
			{
				MessageQueue.Create(path);
			}
		}
		
		private static string CreateMessageQueuePath(string mqName)
		{
			return string.Format(".\\private$\\{0}", mqName);
		}
		
		private static void SendMessage(string mqName, string content)
		{
			var path = CreateMessageQueuePath(mqName);
			
			var mq = new MessageQueue(path);
			
			mq.Send(content);
		}
		
		private static void ReceiveMessage(string mqName)
		{
			var path = CreateMessageQueuePath(mqName);
			
			var mq = new MessageQueue(path);
			
			mq.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });
			
			for (var message = mq.Receive(); message != null; message = mq.Receive())
			{
				Console.WriteLine(message.Body);
			}
		}
	}
}

知识共享许可协议
《测试类》常伟华 创作。
采用 知识共享 署名-相同方式共享 3.0 中国大陆 许可协议进行许可。
相邻依据:发表时间
  • 多说评论
  • 签名
  • 新浪微博
  • 默认评论
  • Tab Header 5

1 条评论 / 点击此处发表评论

Tab Content 5

开发技术


开发平台和工具

sitemap     143.37ms