@@ -16,8 +16,8 @@ namespace ITHit.FileSystem.Samples.Common.Windows
1616 /// </summary>
1717 /// <remarks>
1818 /// This class stores all custom data associated with the item outside of the placeholder.
19- /// We can not store item ID and custom data inside placeholder (using <see cref="IFileSystemItemMetadata.CustomData"/>
20- /// and <see cref="ITHit.FileSystem.Windows.PlaceholderItem.GetCustomData"/>) because of the MS Office transactional save,
19+ /// We can not store item ID and custom data inside of the placeholder (using <see cref="IFileSystemItemMetadata.CustomData"/>
20+ /// and <see cref="ITHit.FileSystem.Windows.PlaceholderItem.GetCustomData"/>) because of the MS Office and AutoCAD transactional save,
2121 /// which renames and deletes the file, so all custom data is lost.
2222 /// </remarks>
2323 public class ExternalDataManager
@@ -80,8 +80,8 @@ public ExternalDataManager(
8080 /// Indicates if the item was saved to the remote storage.
8181 /// </summary>
8282 /// <remarks>
83- /// MS Office transactional save, deletes and recreates the file.
84- /// To detect if this is a new file we must store some marker ouside of the file,
83+ /// MS Office and AutoCAD transactional save, deletes and recreates the file.
84+ /// To detect if this is a new file, we must store some marker ouside of the file,
8585 /// for the marker to survive the transactional save operation.
8686 /// </remarks>
8787 public bool IsNew
@@ -226,68 +226,16 @@ private async Task SetIconAsync(bool set, int id, string iconFile = null, string
226226 }
227227 }
228228
229- /*
230- /// <summary>
231- /// Sets or removes icon.
232- /// </summary>
233- /// <param name="set">True to display the icon. False - to remove the icon.</param>
234- private async Task SetIconAsync(bool set, int? id = null, string iconFile = null, string description = null)
235- {
236- IStorageItem storageItem = await FsPath.GetStorageItemAsync(userFileSystemPath);
237-
238- if (storageItem == null)
239- {
240- // This method may be called on temp files, typically created by MS Office, that exist for a short period of time.
241- // StorageProviderItemProperties.SetAsync(null,) causes AccessViolationException
242- // which is not handled by .NET (or handled by HandleProcessCorruptedStateExceptions) and causes a fatal crush.
243- return;
244- }
245-
246- try
247- {
248- if (set)
249- {
250- StorageProviderItemProperty propState = new StorageProviderItemProperty()
251- {
252- Id = id.Value,
253- Value = description,
254- IconResource = Path.Combine(virtualDrive.Settings.IconsFolderPath, iconFile)
255- };
256- await StorageProviderItemProperties.SetAsync(storageItem, new StorageProviderItemProperty[] { propState });
257- }
258- else
259- {
260- await StorageProviderItemProperties.SetAsync(storageItem, new StorageProviderItemProperty[] { });
261- }
262- }
263-
264- // Setting status icon failes for blocked files.
265- catch (FileNotFoundException)
266- {
267-
268- }
269- catch (COMException)
270- {
271- // "Error HRESULT E_FAIL has been returned from a call to a COM component."
272- }
273- catch (Exception ex)
274- {
275- if (ex.HResult == -2147024499)
276- {
277- // "The operation failed due to a conflicting cloud file property lock. (0x8007018D)"
278- }
279- else
280- {
281- // Rethrow the exception preserving stack trace of the original exception.
282- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(ex).Throw();
283- }
284- }
285- }
286- */
287-
288229 /// <summary>
289- /// Sets or removes read-only attribute on files.
230+ /// Indicates if the item is locked by another user in the remote storage.
231+ /// This will call sets or removes the read-only flag in case the item is a file.
290232 /// </summary>
233+ /// <remarks>
234+ /// Call this method if the item is locked by another user. This will set read-only arrtibute on files.
235+ /// Note that the read-only flag is a convenience-only feature. It does not protect files from modifications.
236+ /// Typically the user will be notified by the application that the item can not be saved if
237+ /// the application tries to update this item.
238+ /// </remarks>
291239 /// <param name="set">True to set the read-only attribute. False - to remove the read-only attribute.</param>
292240 public async Task < bool > SetLockedByAnotherUserAsync ( bool set )
293241 {
@@ -549,25 +497,32 @@ private async Task CustomColumnsMoveToAsync(string userFileSystemNewPath)
549497 /// <summary>
550498 /// Deletes all custom data associated with the item.
551499 /// </summary>
552- public void Delete ( )
500+ /// <param name="recursive">Deletes all data for subfolders if true.</param>
501+ public void Delete ( bool recursive = true )
553502 {
554503 DeleteCustomColumns ( ) ;
555504 ETagManager . DeleteETag ( ) ;
556505 LockManager . DeleteLock ( ) ;
506+
507+ if ( recursive )
508+ {
509+ // If this is a folder, delete all custom columns in this folder.
510+ string customColumnsFolderPath = GetColumnsFilePath ( userFileSystemPath ) ;
511+ if ( Directory . Exists ( customColumnsFolderPath ) )
512+ {
513+ Directory . Delete ( customColumnsFolderPath , true ) ;
514+ }
515+ }
557516 }
558517
559518 /// <summary>
560519 /// Deletes custom columns associated with a file.
561520 /// </summary>
562521 private void DeleteCustomColumns ( )
563522 {
564- File . Delete ( customColumnsFilePath ) ;
565-
566- // If this is a folder, delete all custom columns in this folder.
567- string customColumnsFolderPath = GetColumnsFilePath ( userFileSystemPath ) ;
568- if ( Directory . Exists ( customColumnsFolderPath ) )
523+ if ( File . Exists ( customColumnsFilePath ) )
569524 {
570- Directory . Delete ( customColumnsFolderPath , true ) ;
525+ File . Delete ( customColumnsFilePath ) ;
571526 }
572527 }
573528 }
0 commit comments