Standardize the behavior of CreateFile/CreateFolder across different OS (#20850)
* Truncate the content when writing
To maintain consistency with other operating system APIs, see: https://github.com/AvaloniaUI/Avalonia/pull/20804 & https://github.com/AvaloniaUI/Avalonia/pull/20807
* Prevent accidental truncation when creating files
* Update comments
* Validate existing item type when creating storage
* Truncate files on creation in storage items
---------
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
@ -37,16 +37,20 @@ public interface IStorageFolder : IStorageItem
Task<IStorageFile?>GetFileAsync(stringname);
/// <summary>
/// Creates a file with specified name as a child of the current storage folder
/// Creates, or truncates and overwrites, a file with specified name as a child of the current storage folder.
/// </summary>
/// <param name="name">The display name</param>
/// <returns>A new <see cref="IStorageFile"/> pointing to the moved file. If not null, the current storage item becomes invalid</returns>
/// <returns>
/// A <see cref="IStorageFile"/> that provides read/write access to the file specified in <c>name</c>.
/// </returns>
Task<IStorageFile?>CreateFileAsync(stringname);
/// <summary>
/// Creates a folder with specified name as a child of the current storage folder
/// Creates a folder with specified name as a child of the current storage folder unless they already exist.
/// </summary>
/// <param name="name">The display name</param>
/// <returns>A new <see cref="IStorageFolder"/> pointing to the moved file. If not null, the current storage item becomes invalid</returns>
/// <returns>
/// A <see cref="IStorageFolder"/> that represents the directory at the specified <c>name</c>. This object is returned regardless of whether a directory at the specified <c>name</c> already exists.