12345678910111213141516171819202122 |
- using System;
- using Blue;
- public class GetFileNameUtility : IUtility
- {
- private string fileName="";
- public string GetFileName(string url,string fileType)
- {
- int index = url.IndexOf(fileType);
- if(index<0) throw new Exception("URL下载链接或者文件类型不规范");
- for(int i= index; i>0; i-- )
- {
- if(url[i]=='/')
- {
- fileName = url.Substring(i+1,index-i-1)+fileType;
- break;
- }
- }
- return fileName;
- }
- }
|