//extract filename from url //eg: //http://g-ecx.images-amazon.com/images/G/01/kindle/dp/2012/KC/KC-slate-01-lg._V401028090_.jpg //KC-slate-01-lg._V401028090_.jpg //file:///C:/Users/CLi/AppData/Local/Temp/WindowsLiveWriter-1737927945/supfilesC19F10/now-the-service-status-is-active_thu%5B1%5D.png //now-the-service-status-is-active_thu%5B1%5D.png public string extractFilenameFromUrl(string fullUrl) { string filename = ""; string[] slashList = fullUrl.Split('/'); filename = slashList[slashList.Length - 1]; return filename; }
例 5.9. extractFilenameFromUrl 的使用范例
string imageUrl = imageUrlList[idx]; gLogger.Info(String.Format("[{0}]={1}", idx, imageUrl)); string picFilename = crl.extractFilenameFromUrl(imageUrl);