www.pudn.com > flash_net.rar > mp3services.asmx.cs


using System; 
using System.Collections; 
using System.ComponentModel; 
using System.Data; 
using System.Diagnostics; 
using System.Web; 
using System.Web.Services; 
using System.IO; 
 
namespace flashmp3 
{ 
	///  
	/// mp3services 的摘要说明。 
	///  
	public class mp3services : System.Web.Services.WebService 
	{ 
		public mp3services() 
		{ 
			//CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的 
			InitializeComponent(); 
		} 
		[WebMethod] 
		public ArrayList GeMp3() 
		{ 
			ArrayList mp3List = new ArrayList(); 
			string mp3path = Server.MapPath("mp3"); 
			try 
			{ 
				DirectoryInfo di = new DirectoryInfo(mp3path); 
				FileInfo[] fi = di.GetFiles(); 
				foreach(FileInfo fiTemp in fi) 
				{ 
					if(fiTemp.Extension.ToLower() ==".mp3" || fiTemp.Extension.ToLower() ==".wma") 
					{ 
						mp3List.Add(fiTemp.Name); 
					} 
				} 
			} 
			catch (Exception e) 
			{ 
				Console.WriteLine("The process failed: {0}",e.ToString()); 
			} 
			return mp3List; 
		} 
 
		#region 组件设计器生成的代码 
		 
		//Web 服务设计器所必需的 
		private IContainer components = null; 
				 
		///  
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改 
		/// 此方法的内容。 
		///  
		private void InitializeComponent() 
		{ 
		} 
 
		///  
		/// 清理所有正在使用的资源。 
		///  
		protected override void Dispose( bool disposing ) 
		{ 
			if(disposing && components != null) 
			{ 
				components.Dispose(); 
			} 
			base.Dispose(disposing);		 
		} 
		 
		#endregion 
 
		// WEB 服务示例 
		// HelloWorld() 示例服务返回字符串 Hello World 
		// 若要生成,请取消注释下列行,然后保存并生成项目 
		// 若要测试此 Web 服务,请按 F5 键 
 
//		[WebMethod] 
//		public string HelloWorld() 
//		{ 
//			return "Hello World"; 
//		} 
	} 
}