当前位置: 首页>>代码示例>>C#>>正文


C# String.LastIndexOf方法代码示例

本文整理汇总了C#中System.String.LastIndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# String.LastIndexOf方法的具体用法?C# String.LastIndexOf怎么用?C# String.LastIndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.String的用法示例。


在下文中一共展示了String.LastIndexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetPathRelatedFields

		private void SetPathRelatedFields(String path)
		{
			// Set the path
			this.path = path;

			// Extract the file name from the path
			if (path.IndexOf('/') == -1)
			{
				fileName = path;
			}
			else
			{
				fileName = path.Substring(path.LastIndexOf('/')+1);
			}
			
			// Extract the extension from the file name
			if (fileName.IndexOf('.') == -1)
			{
				extension = String.Empty;
			}
			else
			{
				extension = fileName.Substring(fileName.LastIndexOf('.') + 1);
			}
		}
开发者ID:atczyc,项目名称:castle,代码行数:25,代码来源:RepositoryFile.cs

示例2: Video

 public Video(String url)
 {
     //http://v.iask.com/v_play.php?vid=75314790&uid=1648211320&pid=478&tid=&plid=4001&prid=ja_7_3485822616&referrer=http%3A%2F%2Fcontrol.video.sina.com.cn%2Fcontrol%2Fvideoset%2Findex.php&ran=0.4922798699699342&r=video.sina.com.cn
     this.url = url;
     xmlUrl = @"http://v.iask.com/v_play.php?vid=" +
         url.Substring(url.LastIndexOf('/') + 1, url.LastIndexOf('-') - url.LastIndexOf('/') - 1);
 }
开发者ID:fangxu,项目名称:SVDown,代码行数:7,代码来源:Video.cs

示例3: getFile

        public static String getFile(String deviceId, String fileFullPath)
        {
            int extLength = fileFullPath.Length - fileFullPath.LastIndexOf(".");
            String fileExt = fileFullPath.Substring(fileFullPath.LastIndexOf("."), extLength);

            JSONRequestIndex reqMsg = new JSONRequestIndex(deviceId, fileFullPath);
            JSONMessageWrapper msgWrapper = new JSONMessageWrapper("getFile", reqMsg.request());

            try
            {
                String response = HttpClient.GET("getFile", msgWrapper.getMessage());
                if (!string.IsNullOrEmpty(response))
                {
                    byte[] filebytes = Convert.FromBase64String(response);
                    Guid gid = Guid.NewGuid();
                    FileStream fs = new FileStream(TEMP_LOCATION + gid + fileExt,
                                                   FileMode.CreateNew,
                                                   FileAccess.Write,
                                                   FileShare.None);
                    fs.Write(filebytes, 0, filebytes.Length);
                    fs.Close();
                    return TEMP_LOCATION + gid.ToString() + fileExt;
                }

                return "";
            }
            catch (WebException e)
            {
                //return Device Not Found
                return "DNF";
            }
        }
开发者ID:yungookim,项目名称:slidboard,代码行数:32,代码来源:HttpClient.cs

示例4: findLastSlash

        static int findLastSlash(String path)
        {
            int nPos = path.LastIndexOf('/');
            if (nPos >= 0)
                return nPos;

            return path.LastIndexOf('\\');
        }
开发者ID:rrmartins,项目名称:rhodes,代码行数:8,代码来源:RhoFilePath.cs

示例5: getUrlWithouExt

 private static String getUrlWithouExt( String url )
 {
     int lastDot = url.LastIndexOf( '.' );
     int lastSlash = url.LastIndexOf( '/' );
     if (lastDot > lastSlash)
         return url.Substring( 0, lastDot );
     else
         return url;
 }
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:9,代码来源:PagedDetailSpider.cs

示例6: GetFilename

        internal static string GetFilename(String URL)
        {
            string Filename = URL.Substring(URL.LastIndexOf("/") + 2, URL.Length - URL.LastIndexOf("/") - 2);

            if (Filename.IndexOf("&") != -1)
                Filename = JustBefore(Filename, "&");

            return Filename;
        }
开发者ID:labeuze,项目名称:source,代码行数:9,代码来源:TextUtil.cs

示例7: GetObjectName

        public static String GetObjectName(String myObjectLocation)
        {
            // "/home////" -> "/home"
            while (myObjectLocation.EndsWith(FSPathConstants.PathDelimiter) && !myObjectLocation.Equals(FSPathConstants.PathDelimiter))
                myObjectLocation = myObjectLocation.Substring(0, myObjectLocation.LastIndexOf(FSPathConstants.PathDelimiter));

            if (myObjectLocation.Equals(FSPathConstants.PathDelimiter))
                return "";

            return myObjectLocation.Substring(myObjectLocation.LastIndexOf(FSPathConstants.PathDelimiter) + FSPathConstants.PathDelimiter.Length);
        }
开发者ID:TheByte,项目名称:sones,代码行数:11,代码来源:DirectoryHelper.cs

示例8: VideoItem

 public VideoItem(String path)
 {
     if (path.Contains('\\')) {
         this.path = path;
         this.name = path.Substring(path.LastIndexOf('\\') + 1, path.Length - path.LastIndexOf('\\') - 1);
     } else {
         this.name = path;
     }
     vf = new VideoInfo(path);
     //this.bitRate = vf.BitRate;
 }
开发者ID:fangxu,项目名称:GVideo,代码行数:11,代码来源:VideoItem.cs

示例9: RemoveArgumentFromPath

        public static String RemoveArgumentFromPath(String path)
        {
            if (path.Contains("/")) {
               path = path.Substring(0, path.LastIndexOf("/") );

               }
               if (path.Contains("-")) {
               path = path.Substring(0, path.LastIndexOf("-"));
               }
               return path;
        }
开发者ID:PSanni,项目名称:Sweeper,代码行数:11,代码来源:Extra.cs

示例10: LogHeader

        public LogHeader(String header)
        {
            this.raw = header;

            //Alert sig Line
            int sigIndex = header.IndexOf ("[**]");
            String sig = header.Substring (sigIndex + 4,
                header.LastIndexOf ("[**]") - sigIndex-4).Trim();

            this.alertSig = new AlertSig (sig);

            //Alert
            MatchCollection sigInfos =  Regex.Matches (
                header.Substring(header.LastIndexOf("[**]")), "\\[(.*?)\\]");

            foreach (Match sigInfo in sigInfos) {
                String sigStr =
                    sigInfo.Value.Substring(1,sigInfo.Value.Length-2);

                if (sigStr.IndexOf (":") != -1) {
                    int optionIndex = sigStr.IndexOf (":");
                    String optionKey = sigStr.Substring (0, optionIndex).Trim();
                    String optionValue = sigStr.Substring (optionIndex+1).Trim();

                    switch (optionKey.ToLower ()) {
                    case "classification":
                        this.clasific = optionValue;
                        break;
                    case "priority":
                        this.priority = optionValue;
                        break;
                    }

                }

                if (sigStr.IndexOf ("=>") != -1) {
                    int optionIndex = sigStr.IndexOf ("=>");
                    String optionKey = sigStr.Substring (0, optionIndex).Trim();
                    String optionValue = sigStr.Substring (optionIndex+2).Trim();

                    switch (optionKey.ToLower()) {
                    case "xref":
                        if (xrefList == null) {
                            xrefList = new List<String> ();
                        }
                        xrefList.Add (optionValue);
                        break;
                    }

                }

            }
        }
开发者ID:JSpiner,项目名称:BOB_SnortParser,代码行数:53,代码来源:LogHeader.cs

示例11: extractTypeFromFilename

        private ImageType extractTypeFromFilename(String str)
        {
            ImageType output = ImageType.PROPELLER;

            if (str.Substring(str.LastIndexOf(".") + 1) == "png")
                output = ImageType.IMAGE;

            if (str.Substring(str.LastIndexOf(".") + 1) == "type")
                output = ImageType.TYPE;

            return output;
        }
开发者ID:LauriM,项目名称:PropellerEngine,代码行数:12,代码来源:ArchiveBrowser.cs

示例12: ExtractTrackNumbers

 private static void ExtractTrackNumbers(TrackInfo trackInfo, String content)
 {
     Int32 indexOfOpenParen = content.IndexOf('(');
     Int32 indexOfColon = content.LastIndexOf(':');
     Int32 indexOfCloseParen = content.LastIndexOf(')');
     if (indexOfOpenParen > 1 && indexOfColon > indexOfOpenParen + 1 && indexOfCloseParen > indexOfColon + 1)
     {
         String trackNum = content.Substring(0, indexOfOpenParen - 1);
         String mkvToolsTrackNum = content.Substring(indexOfColon + 2, indexOfCloseParen - (indexOfColon + 2));
         trackInfo.TrackNumber = Int32.Parse(trackNum);
         trackInfo.MkvToolsTrackNumber = Int32.Parse(mkvToolsTrackNum);
     }
 }
开发者ID:boranblok,项目名称:AssortedMkvTools,代码行数:13,代码来源:MKVInfoParser.cs

示例13: notifyIsProductPurchasedAndNotConsumed

 public void notifyIsProductPurchasedAndNotConsumed(String ans)
 {
     Boolean first, second;
     if (ans.Length == 0) {
         return;
     }
     first = setBoolState (ans [0]);
     second = setBoolState (ans [1]);
     String newSku = ans.Substring(2, ans.LastIndexOf(" ") - 2);
     String purchaseId = ans.Substring (ans.LastIndexOf (" "), ans.Length - ans.LastIndexOf(" "));
     if (isProductPurchasedAndNotConsumedAction.ContainsKey(newSku)){
         isProductPurchasedAndNotConsumedAction[newSku](first, second, purchaseId);
     }
 }
开发者ID:JavadAbedi,项目名称:TapsellUnity4Example,代码行数:14,代码来源:TapsellWrapper.cs

示例14: ShapeObject

        public ShapeObject(LayerManager layerManager, String filePath)
        {
            this.layerManager = layerManager;
            this.filePath = filePath;
            this.fileName = filePath.Split('\\')[filePath.Split('\\').Length-1];

            this.access = "rb";
            this.shapePen = new Pen(layerManager.GetRandomColor(), 1.0f);

            int i = filePath.LastIndexOf("\\");

            name = filePath.Substring(i + 1,
                filePath.LastIndexOf(".") - i - 1);
        }
开发者ID:ntj,项目名称:GravurGIS,代码行数:14,代码来源:ShapeObject.cs

示例15: extractFileName

 /// <summary>
 /// Extracts the name of the file.
 /// </summary>
 /// <returns>
 /// The filename only.
 /// </returns>
 /// <param name='fileName'>
 /// Filename with path.
 /// </param>
 public static String extractFileName(String fileName)
 {
     if (fileName.Contains("/"))
     {
         return (fileName.LastIndexOf('/') == 0
                     ? fileName
                     : fileName.Substring(fileName.LastIndexOf('/') + 1));
     }
     else
     {
         return (fileName.LastIndexOf('\\') == 0
                     ? fileName
                     : fileName.Substring(fileName.LastIndexOf('\\') + 1));
     }
 }
开发者ID:GufCab,项目名称:Semester-Projekt---Pi-Program,代码行数:24,代码来源:LIB.cs


注:本文中的System.String.LastIndexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。