本文整理汇总了C#中System.Runtime.InteropServices.StringBuffer.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuffer.Contains方法的具体用法?C# StringBuffer.Contains怎么用?C# StringBuffer.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.InteropServices.StringBuffer
的用法示例。
在下文中一共展示了StringBuffer.Contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewGetCurrentDirectory
private static string NewGetCurrentDirectory()
{
using (StringBuffer buffer = new StringBuffer(PathInternal.MaxShortPath))
{
uint result = 0;
while ((result = Win32Native.GetCurrentDirectoryW(buffer.CharCapacity, buffer.GetHandle())) > buffer.CharCapacity)
{
// Reported size is greater than the buffer size. Increase the capacity.
// The size returned includes the null only if more space is needed (this case).
buffer.EnsureCharCapacity(result);
}
if (result == 0)
__Error.WinIOError();
buffer.Length = result;
#if !PLATFORM_UNIX
if (buffer.Contains('~'))
return LongPathHelper.GetLongPathName(buffer);
#endif
return buffer.ToString();
}
}
示例2: GetCurrentDirectory
/*===============================CurrentDirectory===============================
**Action: Provides a getter and setter for the current directory. The original
** current DirectoryInfo is the one from which the process was started.
**Returns: The current DirectoryInfo (from the getter). Void from the setter.
**Arguments: The current DirectoryInfo to which to switch to the setter.
**Exceptions:
==============================================================================*/
public static String GetCurrentDirectory()
{
// Start with a buffer the size of MAX_PATH
using (StringBuffer buffer = new StringBuffer(260))
{
uint result = 0;
while ((result = Win32Native.GetCurrentDirectoryW(buffer.CharCapacity, buffer.GetHandle())) > buffer.CharCapacity)
{
// Reported size is greater than the buffer size. Increase the capacity.
// The size returned includes the null only if more space is needed (this case).
buffer.EnsureCharCapacity(result);
}
if (result == 0)
__Error.WinIOError();
buffer.Length = result;
#if !PLATFORM_UNIX
if (buffer.Contains('~'))
return Path.GetFullPath(buffer.ToString());
#endif
return buffer.ToString();
}
}