本文整理汇总了C#中IFileSystem.CreateShortcut方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.CreateShortcut方法的具体用法?C# IFileSystem.CreateShortcut怎么用?C# IFileSystem.CreateShortcut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileSystem
的用法示例。
在下文中一共展示了IFileSystem.CreateShortcut方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddMediaPath
/// <summary>
/// Adds an additional mediaPath to an existing virtual folder, within either the default view or a user view
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <param name="virtualFolderName">Name of the virtual folder.</param>
/// <param name="path">The path.</param>
/// <param name="appPaths">The app paths.</param>
/// <exception cref="System.IO.DirectoryNotFoundException">The path does not exist.</exception>
/// <exception cref="System.ArgumentException">The path is not valid.</exception>
public static void AddMediaPath(IFileSystem fileSystem, string virtualFolderName, string path, IServerApplicationPaths appPaths)
{
if (!Directory.Exists(path))
{
throw new DirectoryNotFoundException("The path does not exist.");
}
var rootFolderPath = appPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
var shortcutFilename = fileSystem.GetFileNameWithoutExtension(path);
var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
while (File.Exists(lnk))
{
shortcutFilename += "1";
lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
}
fileSystem.CreateShortcut(lnk, path);
}
示例2: AddMediaPath
/// <summary>
/// Adds an additional mediaPath to an existing virtual folder, within either the default view or a user view
/// </summary>
/// <param name="fileSystem">The file system.</param>
/// <param name="virtualFolderName">Name of the virtual folder.</param>
/// <param name="path">The path.</param>
/// <param name="user">The user.</param>
/// <param name="appPaths">The app paths.</param>
/// <exception cref="System.ArgumentException">The path is not valid.</exception>
/// <exception cref="System.IO.DirectoryNotFoundException">The path does not exist.</exception>
public static void AddMediaPath(IFileSystem fileSystem, string virtualFolderName, string path, User user, IServerApplicationPaths appPaths)
{
if (!Directory.Exists(path))
{
throw new DirectoryNotFoundException("The path does not exist.");
}
// Strip off trailing slash, but not on drives
path = path.TrimEnd(Path.DirectorySeparatorChar);
if (path.EndsWith(":", StringComparison.OrdinalIgnoreCase))
{
path += Path.DirectorySeparatorChar;
}
var rootFolderPath = user != null ? user.RootFolderPath : appPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
ValidateNewMediaPath(fileSystem, rootFolderPath, path, appPaths);
var shortcutFilename = Path.GetFileNameWithoutExtension(path);
var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
while (File.Exists(lnk))
{
shortcutFilename += "1";
lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
}
fileSystem.CreateShortcut(lnk, path);
}