0

I am developing an application that manages files. For the GUI, I am using UWP. I have enabled the capabilities for the File System (in Package.appxmanifest). I want to check if the File System on each volume in PC is NTFS.

I tried:

to call DriveFormat from DriveInfo, but there is thrown exception: System.UnauthorizedAccessException: 'Access to the path 'C:' is denied.' Why? I have enabled the capabilities for the File System.

DriveInfo[] drives = DriveInfo.GetDrives();

foreach (DriveInfo d in drives)
{
      d.DriveFormat;
}

I have also run Visual Studio as administrator and the same exception is thrown.

I met a similar situation few months ago, when I needed the used space percentage on volume, and the same exception was thrown. To solve the problem with the used space in the drive, I have used StorageFolder.

const string PERCENT_FULL = "System.PercentFull";
StorageFolder storageFolder = await StorageFolder.GetFolderFromPathAsync(d.RootDirectory.FullName);
var properties = await storageFolder.Properties.RetrievePropertiesAsync(new string[] { PERCENT_FULL });

Can I check the file system type on the volume with StorageFolder? I have searched on https://learn.microsoft.com/en-us/windows/win32/properties/core-bumper to see if any property could solve my problem, but I did not find anything.

Is there any possibility to check the file system in UWP?

1
  • Any updates for this thread ? Commented Jun 23, 2021 at 9:04

1 Answer 1

0

Check if NTFS is file system of volume in UWP

Currently, UWP does not contain such api could detect the disk's device format, for your requirement, the better way is use desktop extension to load DeviceFormat and write to local storage, and load above info from UWP platform.

For example

DriveInfo[] allDrives = DriveInfo.GetDrives();

        foreach (DriveInfo d in allDrives)
        {
            Console.WriteLine("Drive {0}", d.Name);
            Console.WriteLine("  Drive type: {0}", d.DriveType);
            if (d.IsReady == true)
            {
                Console.WriteLine("  Volume label: {0}", d.VolumeLabel);
                Console.WriteLine("  File system: {0}", d.DriveFormat);
                Console.WriteLine(
                    "  Available space to current user:{0, 15} bytes",
                    d.AvailableFreeSpace);

                Console.WriteLine(
                    "  Total available space:          {0, 15} bytes",
                    d.TotalFreeSpace);

                Console.WriteLine(
                    "  Total size of drive:            {0, 15} bytes ",
                    d.TotalSize);
            }
        }
 

And using desktop-bridge please refer stefan's blog UWP with Desktop Extension

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.