本文整理汇总了C#中FOS_System.Split方法的典型用法代码示例。如果您正苦于以下问题:C# FOS_System.Split方法的具体用法?C# FOS_System.Split怎么用?C# FOS_System.Split使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FOS_System
的用法示例。
在下文中一共展示了FOS_System.Split方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetListing
/// <summary>
/// Gets the listing for the specified file or directory.
/// </summary>
/// <param name="aName">The full path to the file or directory.</param>
/// <returns>The listing or null if not found.</returns>
public override Base GetListing(FOS_System.String aName)
{
if (aName == "")
{
return RootDirectory_FAT32;
}
else
{
List nameParts = aName.Split(FileSystemManager.PathDelimiter);
List listings = GetRootDirectoryListings();
return GetListingFromListings(nameParts, null, listings);
}
}
示例2: SplitCommand
/// <summary>
/// Splits the input string into commands including handling quoted parts.
/// </summary>
/// <param name="input">The input to split.</param>
/// <returns>The list of command parts.</returns>
private List SplitCommand(FOS_System.String input)
{
//This method splits the input into parts separated by spaces
// However, it must then also search for grouped parts which
// are indicated by start and end quote marks (").
//Split the input by space
List parts = input.Split(' ');
//Create a list for the result - capacity 4 is the usual maximum we expect so this just
// optimises the internal array creation a bit.
List result = new List(4);
//Stores the current part being constructed.
FOS_System.String currPart = "";
//Indicates whether we are constructing a grouped part or not.
bool waitingForCloseQuote = false;
//Loop through all parts
for(int i = 0; i < parts.Count; i++)
{
//If we are constructing a grouped part
if (waitingForCloseQuote)
{
//Add the part (including the space which was removed by split)
// to the currently constructing part
currPart += " " + (FOS_System.String)parts[i];
//If the part ends with a quote, then we have found our closing quote
// which terminates the group part
if(currPart.EndsWith("\""))
{
//Remove the closing quote
currPart = currPart.Substring(0, currPart.length - 1);
//End the search
waitingForCloseQuote = false;
//Add the part to the result
result.Add(currPart.ToLower());
}
}
else
{
//Set the current part
currPart = (FOS_System.String)parts[i];
//If it starts with a quote, it is the start of a group part
if(currPart.StartsWith("\""))
{
//If it ends with a quote, it is also the end of the group part
// so essentially the user grouped something which didn't
// actually contain any spaces.
if (currPart.EndsWith("\""))
{
//Remove the start and end quotes
currPart = currPart.Substring(1, currPart.length - 2);
//Add the part to the result
result.Add(currPart.ToLower());
}
else
{
//Remove the start quote
currPart = currPart.Substring(1, currPart.length - 1);
//Begin the search for the end of the group part
waitingForCloseQuote = true;
}
}
else
{
//This is a normal, ungrouped part so just add it to
// the result
result.Add(currPart.ToLower());
}
}
}
return result;
}
示例3: GetShortName
/// <summary>
/// Gets the short name for the specified long name.
/// </summary>
/// <param name="longName">The long name to shorten.</param>
/// <param name="isDirectory">Whether the long name is for a directory or not.</param>
/// <returns>The short name parts. Directory=1 part, file=2 parts (name + extension).</returns>
private static List GetShortName(FOS_System.String longName, bool isDirectory)
{
if (isDirectory)
{
List result = new List(1);
result.Add(longName.Substring(0, 8).PadRight(11, ' '));
return result;
}
else
{
List result = new List(2);
List nameParts = longName.Split('.');
if (nameParts.Count > 1)
{
result.Add(((FOS_System.String)nameParts[0]).Substring(0, 8).PadRight(8, ' '));
result.Add(((FOS_System.String)nameParts[1]).Substring(0, 3).PadRight(3, ' '));
}
else
{
result.Add(longName.Substring(0, 8).PadRight(8, ' '));
result.Add(((FOS_System.String)"").PadRight(3, ' '));
}
return result;
}
}