本文整理汇总了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);
}
}
示例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);
}
示例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";
}
}
示例4: findLastSlash
static int findLastSlash(String path)
{
int nPos = path.LastIndexOf('/');
if (nPos >= 0)
return nPos;
return path.LastIndexOf('\\');
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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));
}
}