函数|文件名
#region 获取网址中域名,目录,文件名的函数
public string GetUrlDomainName(string strHtmlPagePath)
{
string p = "http://[^\.]*\.(?<domain>[^/]*)";
Regex reg = new Regex(p,RegexOptions.IgnoreCase);
Match m = reg.Match(strHtmlPagePath);
return m.Groups["domain"].Value;
}
public string[] GetUrlFolerName(string strHtmlPagePath)
{
//抓取网址字符串中的文件目录
int at = 0;
int start = 0;
int notei=0;
int endi=0;
int[] myIntArray =new int[10];
string[] ArrayFolderName=null;
string NewFolderName;
while((start < strHtmlPagePath.Length) && (at > -1))
{
at = strHtmlPagePath.IndexOf('/', start);
if (at == -1) break;
myIntArray[notei]=at;
start = at+1;
notei = notei+1;
endi=at;
}
ArrayFolderName=new string[notei-1];
for(int i=0;i<notei;i++)
{
if(myIntArray[i]>0)
{
if (myIntArray[i+1]>0)
{
NewFolderName=strHtmlPagePath.Substring(myIntArray[i]+1,myIntArray[i+1]-myIntArray[i]-1);
ArrayFolderName.SetValue(NewFolderName,i);
}
}
}
return ArrayFolderName;
}
public string GetUrlFileName(string strHtmlPagePath)
{
//抓取网址字符串中的文件名称
int at = 0;
int start = 0;
int notei=0;
int endi=0;
int[] myIntArray = new int[10];
string Name="";
while((start < strHtmlPagePath.Length) && (at > -1))
{
at = strHtmlPagePath.IndexOf('/', start);
if (at == -1) break;
myIntArray[notei]=at;
start = at+1;
notei = notei+1;
endi=at;
}
for(int i=0;i<notei;i++)
{
if(myIntArray[i]>0)
{
if (myIntArray[i+1]==0)
{
Name=strHtmlPagePath.Substring(myIntArray[i]+1,strHtmlPagePath.Length-myIntArray[i]-1);
}
}
}
return Name.ToLower();
}
#endregion