本文整理汇总了C#中Primitive.GetItemCount方法的典型用法代码示例。如果您正苦于以下问题:C# Primitive.GetItemCount方法的具体用法?C# Primitive.GetItemCount怎么用?C# Primitive.GetItemCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Primitive
的用法示例。
在下文中一共展示了Primitive.GetItemCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllVerbsFor
/// <summary>Gets all available Verbs (contextmenu items) for a given filetype or folder as Array.
/// Applying of a Verb on file/folder under see 'ApplyVerbOn'.</summary>
/// <param name="path">The full file- or folder path.</param>
/// <returns>All available Verbs as Array ("idx=verb;...", w/o '&') on success, else "FAILED".</returns>
public static Primitive GetAllVerbsFor(Primitive path)
{
string fo = Environment.ExpandEnvironmentVariables(path);
if (!System.IO.File.Exists(fo) && !Directory.Exists(fo)) return "FAILED";
char[] charsTrim = { ' ', '\'' };
fo = fo.Trim(charsTrim);
string fDir = Path.GetDirectoryName(fo);
string fNameExt = Path.GetFileName(fo);
Primitive result = new Primitive();
try
{
Shell32.Folder fold = GetShell32NameSpace(fDir);
Shell32.FolderItem foldItem = fold.ParseName(fNameExt);
Shell32.FolderItemVerbs verbs = foldItem.Verbs();
for (int i = 0; i < verbs.Count; i++)
{
Shell32.FolderItemVerb vrb = verbs.Item(i);
string verbName = vrb.Name.Replace(@"&", string.Empty);
if (verbName.Length > 0) result[result.GetItemCount() + 1] = verbName;
}
return result;
}
catch
{ return "FAILED"; }
}
示例2: SpecialFolderList
/// <summary>Gets all items in a special system/shell folder (upper level only).</summary>
/// <param name="csidl">The CSIDL number of the system folder (0 to 47, constants and names of available folders under s. SpecialFolderConstants).</param>
/// <returns>The names of all objects in the system folder as Array (only upper level) on success, else "FAILED".</returns>
/// <example>http://msdn.microsoft.com/library/bb774096.aspx
/// eg. CSIDL for:
/// 3 Control panel
/// 5 my documents
/// 8 Recent
/// 9 SendTo
/// 10 RecBin
/// 16 Desktop folder
/// 17 Computer
/// 20 Fonts
/// 32 Temp Inet Files</example>
public static Primitive SpecialFolderList(Primitive csidl)
{
int nFold = csidl;
if (nFold < 0 || nFold > 47) return "FAILED";
string itemName;
Primitive content = new Primitive();
try
{
Shell32.Folder fold = GetShell32NameSpace(nFold);
Shell32.FolderItems foldItems = fold.Items();
foreach (Shell32.FolderItem item in foldItems)
{
itemName = item.Name; //Path;
if (Path.GetExtension(itemName) == "") itemName += Path.GetExtension(item.Path);
// //Necessary for systems with hidden file extensions.
content[content.GetItemCount() + 1] = itemName;
}
return content;
}
catch
{ return "FAILED"; }
}
示例3: GetAllDetailNamesFor
/// <summary>Gets the names of all available extended properties for a given file or folder as Array (up to max. 316, w/o -1=Infotip).</summary>
/// <param name="path">The full file- or folder path.</param>
/// <param name="step1">Indizes in speps by 1? "True" or "False" (default, real property ID).</param>
/// <returns>The names of all available extended properties as Array ("idx=property name;...", w/o Infotip) on success, else "FAILED".</returns>
public static Primitive GetAllDetailNamesFor(Primitive path, Primitive step1)
{
string fo = Environment.ExpandEnvironmentVariables(path);
if (!System.IO.File.Exists(fo) && !Directory.Exists(fo)) return "FAILED";
char[] charsTrim = { ' ', '\'' };
fo = fo.Trim(charsTrim);
string prop;
string header;
Primitive details = new Primitive();
string fDir = Path.GetDirectoryName(fo);
string fNameExt = Path.GetFileName(fo);
try
{
Shell32.Folder fold = GetShell32NameSpace(fDir);
Shell32.FolderItem foldItem = fold.ParseName(fNameExt);
for (int i = 0; i <= 316; i++) // 286 (Win7)
{
prop = fold.GetDetailsOf(foldItem, i).ToString();
if (!String.IsNullOrEmpty(prop))
{
header = fold.GetDetailsOf(fold.Items(), i).ToString();
if (step1)
details[details.GetItemCount() + 1] = header;
else
details[i] = header;
}
}
return details;
}
catch
{ return "FAILED"; }
}