C#根据网址获取域名,目录名,文件名函数
来源:互联网 发布:种族 知乎 编辑:程序博客网 时间:2024/05/17 04:41
#region 获取网址中域名,目录,文件名的函数
public string GetUrlDomainName(string strHtmlPagePath)
{
string p = @"http://[^\.]*\.(?<domain>[^\.]*)";
Regex reg = new Regex(p, RegexOptions.IgnoreCase);
Match m = reg.Match(HostUrl);
Result=m.Groups["domain"].Value;
}
public string GetUrlDomainName(string strHtmlPagePath)
{
string p = @"(?<=http://)[\w\.]+[^/]";
Regex reg = new Regex(p, RegexOptions.IgnoreCase);
Match m = reg.Match(strHtmlPagePath);
return m.Groups[0].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 NewFileName="";
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)
{
NewFileName=strHtmlPagePath.Substring(myIntArray[i]+1,strHtmlPagePath.Length-myIntArray[i]-1);
}
}
}
return NewFileName.ToLower();
}
#endregion
- C#根据网址获取域名,目录名,文件名函数
- 从网址中获取域名,目录名,文件名的C#方法
- C#根据网址抓取目录和文件名的两个函数
- C#根据路径获取文件名
- shell中获取某个目录下全部的子文件名,java根据包名分批打包
- GetFiles GetDirectories 获取文件名,目录名排序
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名。
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- python 获取当前行号 函数名 文件名
- 根据域名获取IP地址 gethostbyname()函数
- C#中获取当前执行的函数名、代码行、源码文件名
- C#根据控件名获取控件对象
- C#根据控件名获取控件对象
- Java获取文件名/类名/函数名/行号的方法
- linux shell获取路径的文件名及其目录名
- 牛刀小小试 PHP5中PDO的简单使用
- C++中的预编译
- 有关Goldbach猜想的几个趣事zz
- VC中常用的20种方法
- 一个可能破解所有公钥密码的方法
- C#根据网址获取域名,目录名,文件名函数
- 一个有趣的象棋残局
- ruby学习笔记(5)-简单数据类型
- 整理了1000多个java开源项目,并且分类介绍[中文]
- s60的字符串描述符翻译
- 非常不错ALV GRID CONTROL 教材
- 十年学会编程
- 设置全屏显示的S60程序--
- 八种酒吧里最时尚的喝酒法