PlaceholderFolderCreatePlaceholders Method |
Namespace: ITHit.FileSystem.Windows
Exception | Condition |
---|---|
ExistsException | Thrown if any a file or folder with the name specified in the list exists. |
The code below is part of 'VirtualFileSystem' C# sample provided with the SDK.
internal static async Task<uint> CreateAsync(string userFileSystemParentPath, FileSystemItemBasicInfo[] newItemsInfo) { try { // Because of the on-demand population the file or folder placeholder may not exist in the user file system. // Here we also check that the folder content was loaded into user file system (the folder is not offline). if (Directory.Exists(userFileSystemParentPath) && !new DirectoryInfo(userFileSystemParentPath).Attributes.HasFlag(System.IO.FileAttributes.Offline)) { // Create placeholders. uint created = new PlaceholderFolder(userFileSystemParentPath).CreatePlaceholders(newItemsInfo); // Create ETags. foreach (FileSystemItemBasicInfo child in newItemsInfo) { string userFileSystemItemPath = Path.Combine(userFileSystemParentPath, child.Name); await ETag.SetETagAsync(userFileSystemItemPath, child.ETag); } return created; } } catch (ExistsException ex) { // "Cannot create a file when that file already exists." //await new UserFileSystemItem(userFileSystemParentPath).ShowDownloadErrorAsync(ex); // Rethrow the exception preserving stack trace of the original exception. System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(ex).Throw(); } return 0; }
internal static async Task<uint> CreateAsync(string userFileSystemParentPath, FileSystemItemBasicInfo[] newItemsInfo) { try { // Because of the on-demand population the file or folder placeholder may not exist in the user file system. // Here we also check that the folder content was loaded into user file system (the folder is not offline). if (Directory.Exists(userFileSystemParentPath) && !new DirectoryInfo(userFileSystemParentPath).Attributes.HasFlag(System.IO.FileAttributes.Offline)) { // Create placeholders. uint created = new PlaceholderFolder(userFileSystemParentPath).CreatePlaceholders(newItemsInfo); // Create ETags. foreach (FileSystemItemBasicInfo child in newItemsInfo) { string userFileSystemItemPath = Path.Combine(userFileSystemParentPath, child.Name); await ETag.SetETagAsync(userFileSystemItemPath, child.ETag); // Set the lock icon and read-only attribute, to indicate that the item is locked by another user. await new UserFileSystemRawItem(userFileSystemItemPath).SetLockedByAnotherUserAsync(child.LockedByAnotherUser); } return created; } } catch (ExistsException ex) { // "Cannot create a file when that file already exists." //await new UserFileSystemItem(userFileSystemParentPath).ShowDownloadErrorAsync(ex); // Rethrow the exception preserving stack trace of the original exception. System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(ex).Throw(); } return 0; }