📄 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
{
/// <summary>
/// mp3services 的摘要说明。
/// </summary>
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;
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
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";
// }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -