本文整理汇总了C#中IFolderInfo类的典型用法代码示例。如果您正苦于以下问题:C# IFolderInfo类的具体用法?C# IFolderInfo怎么用?C# IFolderInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IFolderInfo类属于命名空间,在下文中一共展示了IFolderInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenameFiles
private void RenameFiles(IFolderInfo folder, string newFolderPath)
{
var files = FolderManager.Instance.GetFiles(folder);
foreach (var file in files)
{
file.Folder = newFolderPath;
FileManager.Instance.UpdateFile(file);
}
}
示例2: Folder
/// <summary>
/// Get the folder specified in App.Settings (BasePath) combined with the module's ID
/// Will create the folder if it does not exist
/// </summary>
private IFolderInfo Folder(Guid entityGuid, string fieldName)
{
if (_folder == null)
{
var folderManager = FolderManager.Instance;
var basePath = AdamAppRootFolder.Replace("[AppFolder]", App.Folder);
var path = AdamFolderMask
.Replace("[AppFolder]", App.Folder)
.Replace("[Guid22]", GuidHelpers.Compress22(entityGuid))
.Replace("[FieldName]", fieldName);
// create all folders to ensure they exist. Must do one-by-one because dnn must have it in the catalog
var pathParts = path.Split('/');
var pathToCheck = ""; // pathParts[0];
for (var i = 0; i < pathParts.Length; i++) {
pathToCheck += pathParts[i] + "/";
if (!folderManager.FolderExists(Dnn.Portal.PortalId, pathToCheck))
folderManager.AddFolder(Dnn.Portal.PortalId, pathToCheck);
}
_folder = folderManager.GetFolder(Dnn.Portal.PortalId, path);
}
return _folder;
}
示例3: CreateFile
private static string CreateFile(IFolderInfo folder, string fileName, string contentType, Stream fileContent, bool unzip, bool overwrite, bool checkPermissions)
{
var strMessage = "";
var fileManager = FileManager.Instance;
try
{
var file = fileManager.AddFile(folder, fileName, fileContent, overwrite, checkPermissions, contentType);
if (unzip && file.Extension == "zip")
{
fileManager.UnzipFile(file, folder);
}
}
catch (PermissionsNotMetException)
{
strMessage += "<br />" + string.Format(Localization.GetString("InsufficientFolderPermission"), folder.FolderPath);
}
catch (NoSpaceAvailableException)
{
strMessage += "<br />" + string.Format(Localization.GetString("DiskSpaceExceeded"), fileName);
}
catch (InvalidFileExtensionException)
{
strMessage += "<br />" + string.Format(Localization.GetString("RestrictedFileType"), fileName, Host.AllowedExtensionWhitelist.ToDisplayString());
}
catch (Exception ex)
{
DnnLog.Error(ex);
strMessage += "<br />" + string.Format(Localization.GetString("SaveFileError"), fileName);
}
return strMessage;
}
示例4: GetFiles
public override string[] GetFiles(IFolderInfo folder)
{
Requires.NotNull("folder", folder);
var fileNames = DirectoryWrapper.Instance.GetFiles(folder.PhysicalPath);
for (var i = 0; i < fileNames.Length; i++)
{
var fileName = Path.GetFileName(fileNames[i]);
if (!fileName.EndsWith(ProtectedExtension, StringComparison.InvariantCultureIgnoreCase))
{
var destFileName = fileNames[i] + ProtectedExtension;
if (FileWrapper.Instance.Exists(destFileName))
FileWrapper.Instance.Delete(destFileName);
FileWrapper.Instance.Move(fileNames[i], destFileName);
}
else
{
fileName = fileName.Substring(0, fileName.LastIndexOf(ProtectedExtension, StringComparison.InvariantCultureIgnoreCase));
}
fileNames[i] = fileName;
}
return fileNames;
}
示例5: AddFile
public override void AddFile(IFolderInfo folder, string fileName, Stream content)
{
Requires.NotNull("folder", folder);
Requires.NotNullOrEmpty("fileName", fileName);
Requires.NotNull("content", content);
UpdateFile(folder, fileName, content);
}
示例6: AddFolder
private void AddFolder(IFolderInfo fldr)
{
_folderIds.Add(fldr.FolderID); // track of the folder
AddFilesInFolder(fldr); // keep track of the files
foreach (var f in _fldm.GetFolders(fldr)) // then add subfolders
AddFolder(f);
}
示例7: MoveFolders
private void MoveFolders(IFolderInfo folder, string newFolderPath)
{
var folderInfos = FolderManager.Instance.GetFolders(folder.PortalID).Where(f => f.FolderPath != string.Empty && f.FolderPath.StartsWith(folder.FolderPath)).ToList();
foreach (var folderInfo in folderInfos)
{
var folderPath = newFolderPath + folderInfo.FolderPath.Substring(folder.FolderPath.Length);
MoveFolder(folderPath, folderInfo);
}
}
示例8: GetFolderHierarchy
public static IEnumerable<IFolderInfo> GetFolderHierarchy(IFolderInfo folderInfo)
{
List<IFolderInfo> res = new List<IFolderInfo>();
while (folderInfo != null && folderInfo.Id != ""){
res.Add(folderInfo);
folderInfo = (folderInfo as FolderInfo).GetParent(instance.baseDir);
}
res.Reverse();
return res;
}
示例9: AdamItem
public AdamItem(IFolderInfo original)
{
IsFolder = true;
Id = original.FolderID;
ParentId = original.ParentID;
Path = original.DisplayPath;
Name = original.DisplayName;
Size = 0;
Type = "folder";
}
示例10: MoveFolder
public IFolderInfo MoveFolder(IFolderInfo folder, string newFolderPath)
{
Requires.NotNull("folder", folder);
Requires.NotNullOrEmpty("newFolderPath", newFolderPath);
newFolderPath = PathUtils.Instance.FormatFolderPath(newFolderPath);
if (folder.FolderPath == newFolderPath) return folder;
MoveFolders(folder, newFolderPath);
return FolderManager.Instance.GetFolder(folder.FolderID);
}
示例11: checkFolderPermissions
public static void checkFolderPermissions(int PortalId, IFolderInfo theFolder, int theUserId, List<UserInfo> approvers)
{
// Get the write permission
PermissionController pc = new PermissionController();
PermissionInfo w = (PermissionInfo)pc.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "WRITE")[0];
// Get a list of all the folderPermissions we currently have
FolderPermissionCollection folderPermissions = theFolder.FolderPermissions;
// Set up the first permission
FolderPermissionInfo permission = new FolderPermissionInfo();
// Set up some default values for the permission
initFolderPermission(permission, theFolder.FolderID, PortalId, w.PermissionID);
// Set the user id to be this user
permission.UserID = theUserId;
// Add folder permissions, with a check for duplicates.
// This duplicate check (the 'True' parameter) will classify this as a "duplicate" if this permission
// has the same PermissionID, UserID, and RoleID as a pre-existing one, and not add it if it is a duplicate
folderPermissions.Add(permission, true);
// Get all the possible approvers for this reimbursement
try
{
foreach (var approver in approvers)
{
// Create a new permission for this approver
permission = new FolderPermissionInfo();
// Initialize all the variables
initFolderPermission(permission, theFolder.FolderID, PortalId, w.PermissionID);
// Set the userid to the approver's id
permission.UserID = approver.UserID;
// Add permission for approver
folderPermissions.Add(permission, true);
}
}
catch { }
// Finally, add permissions for the accounts team:
try
{
permission = new FolderPermissionInfo();
// Initialize new folder permission
initFolderPermission(permission, theFolder.FolderID, PortalId, w.PermissionID);
// Set the role ID
DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
permission.RoleID = rc.GetRoleByName(PortalId, "Accounts Team").RoleID;
folderPermissions.Add(permission, true);
}
catch { }
// Once we're finished adding these folder permissions, save it all
FolderPermissionController.SaveFolderPermissions(theFolder);
}
示例12: GetChildren
// ReSharper disable LoopCanBeConvertedToQuery
private List<Item> GetChildren(IFolderInfo folder, ICollection<string> extensions)
{
var everything = new List<Item>();
var folders = _folderManager.GetFolders(folder);
foreach (var currentFolder in folders)
{
everything.Add(new Item
{
id = currentFolder.FolderID,
name = currentFolder.DisplayName ?? currentFolder.FolderName,
folder = true,
parentId = folder.FolderID,
children = GetChildren(currentFolder, extensions)
});
}
var files = _folderManager.GetFiles(folder);
foreach (var file in files)
{
// list is empty or contains the file extension in question
if (extensions.Count == 0 || extensions.Contains(file.Extension.ToLowerInvariant()))
{
everything.Add(new Item
{
id = file.FileId,
name = file.FileName,
folder = false,
parentId = file.FolderId,
thumb_url = GetThumbUrl(file),
type = GetTypeName(file),
size = GetFileSize(file.Size),
modified = GetModifiedTime(file.LastModificationTime)
});
}
}
return everything;
}
示例13: GetFiles
public override string[] GetFiles(IFolderInfo folder)
{
Requires.NotNull("folder", folder);
var fileNames = DirectoryWrapper.Instance.GetFiles(folder.PhysicalPath);
for (var i = 0; i < fileNames.Length; i++)
{
var fileName = Path.GetFileName(fileNames[i]);
if(!fileName.EndsWith(ProtectedExtension))
{
FileWrapper.Instance.Move(fileNames[i], fileNames[i] + ProtectedExtension);
}
else
{
fileName = fileName.Substring(0, fileName.LastIndexOf(ProtectedExtension));
}
fileNames[i] = fileName;
}
return fileNames;
}
示例14: GetFolderViewModel
protected virtual FolderViewModel GetFolderViewModel(IFolderInfo folder)
{
var folderName = string.IsNullOrEmpty(folder.FolderName)
? LocalizationHelper.GetString("RootFolder.Text")
: folder.FolderName;
var folderViewModel = new FolderViewModel
{
FolderID = folder.FolderID,
FolderMappingID = folder.FolderMappingID,
FolderName = folderName,
FolderPath = folder.FolderPath,
PortalID = folder.PortalID,
LastModifiedOnDate = folder.LastModifiedOnDate.ToString("g"),
IconUrl = GetFolderIconUrl(folder.PortalID, folder.FolderMappingID),
Permissions = GetPermissionViewModelCollection(folder),
HasChildren = folder.HasChildren
};
folderViewModel.Attributes.Add(new KeyValuePair<string, object>("UnlinkAllowedStatus", GetUnlinkAllowedStatus(folder)));
return folderViewModel;
}
示例15: ShowFilesIn
/// <summary>
/// Shows the files in directory.
/// </summary>
/// <param name="currentFolderInfo">The current folder information.</param>
/// <param name="pagerChanged">if set to <c>true</c> [pager changed].</param>
private void ShowFilesIn(IFolderInfo currentFolderInfo, bool pagerChanged = false)
{
this.CheckFolderAccess(currentFolderInfo.FolderID, false);
if (!pagerChanged)
{
this.FilesTable = this.GetFiles(currentFolderInfo);
this.GetDiskSpaceUsed();
}
else
{
if (this.FilesTable == null)
{
this.FilesTable = this.GetFiles(currentFolderInfo);
}
}
var filesPagedDataSource = new PagedDataSource { DataSource = this.FilesTable.DefaultView };
if (this.currentSettings.FileListPageSize > 0)
{
filesPagedDataSource.AllowPaging = true;
filesPagedDataSource.PageSize = this.currentSettings.FileListPageSize;
filesPagedDataSource.CurrentPageIndex = pagerChanged ? this.PagerFileLinks.CurrentPageIndex : 0;
}
this.PagerFileLinks.PageCount = filesPagedDataSource.PageCount;
this.PagerFileLinks.RessourceFile = this.ResXFile;
this.PagerFileLinks.LanguageCode = this.LanguageCode;
this.PagerFileLinks.Visible = filesPagedDataSource.PageCount > 1;
// this.FilesList.DataSource = this.GetFiles(directory);
this.FilesList.DataSource = filesPagedDataSource;
this.FilesList.DataBind();
}