This section describes the platform-specific differences with the file system helpers. Using StreamWriter streamWriter = new StreamWriter(outputStream) Using FileStream outputStream = System.IO.File.OpenWrite(targetFile) String targetFile = System.IO.Path.Combine(, targetFileName) Write the file content to the app data directory ![]() Transform file content to upper case text String content = await reader.ReadToEndAsync() Using Stream fileStream = await (sourceFile) ![]() The following example uses OpenAppPackageFileAsync to read a bundled file, alters it, and then writes it to the app data folder: public async Task ConvertFileToUpperCase(string sourceFile, string targetFileName) But you can read it first, then write it back to the cache directory or app data directory. Writing from a bundled file to the app data folder Using StreamReader reader = new StreamReader(fileStream) Using Stream fileStream = await (filePath) Wait for the extraction process to finish. Select the RAR file you want to open, and click Upload. The following example demonstrates using a method to read the text contents of a file: public async Task ReadTextFile(string filePath) Here’s how to open RAR files on a Mac with Unzip Online: Navigate to the Unzip Online uncompress file page, and click Choose File. This method returns a read-only Stream representing the file contents. To open a file that is bundled into the app package, use the OpenAppPackageFileAsync method and pass the file name. These files are backed up with the operating system syncing framework. To get the app's top-level directory for any files that aren't user data files. Cache data can be used for any data that needs to persist longer than temporary data, but shouldn't be data that is required to operate the app, as the operating system may clear this storage. To get the application's directory to store cache data. The IFileSystem interface provides a cross-platform API for accessing these directory paths. ![]() Using file system helpersĮach operating system will have unique paths to the app cache and app data directories. Both the IFileSystem interface and FileSystem class are contained in the namespace. The default implementation of the IFileSystem interface is available through the FileSystem.Current property. This interface provides helper methods that access the app's cache and data directories, and helps access files in the app package. NET Multi-platform App UI (.NET MAUI) IFileSystem interface. This article describes how you can use the.
0 Comments
Leave a Reply. |