當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。