-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[Post 2.3] struct VolumeInfo #9226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The GetVolumeInformation win32 function is available in UWP. Could it avoid having to call the fulltrust process for this? |
@gave92 Did you manage to use it? I tried several months ago. We can extract several pieces of information, but the volumeid is always empty. I had found information saying that you needed FullTrust rights to access this information. I just stayed and it returns me an empty string. |
It looks like the only thing you can get from UWP is the "FileID" not the Volume ID. File ID might be enough for the purpose of tracking folders even if it's not guaranteed to be unique across volumes (though for file tags I'm ignoring this fact hoping that chances of collisions are low enough). |
OK, last attempt to avoid having to use the fulltrust process for this 😆, does the following code retrieve the correct info? var folder = await StorageFolder.GetFolderFromPathAsync(@"C:\Users\Marco Gavelli\source\repos\Files");
var extra = await folder.Properties.RetrievePropertiesAsync(new string[] { "System.FileFRN", "System.VolumeId" });
//Debug.WriteLine($"Folder ID: {(ulong?)extra["System.FileFRN"]}");
Debug.WriteLine($"Volume ID: {(Guid)extra["System.VolumeId"]}"); |
@gave92 That doesn't work either. The value of extra["System.VolumeId"] always is null, not a Guid. |
Sure enough, I was using the root. I managed to get the guid with your method. It also works for StorageFile. However, it has 2 problems:
For performance, I can modify the factory to only use FullTrust when needed. |
@gave92 There are now 3 factories: FullTrustVolumeInfoFactory, StorageVolumeInfoFactory and VolumeInfoFactory. The latter uses the Storage method, but if it fails (for example if the drive is empty), it uses the FullTrust method. |
Ouch my suggestion was in the hope to reduce code not increase it xD. |
This reverts commit 6eddd75.
I approve. |
Resolved / Related Issues
The VolumeId uniquely identifies a drive. The current code does not give us access to this information.
This information is necessary to be able to keep the sizes of the folders between sessions because the disks may have changed paths (especially removable disks).
This can also be useful information to display in disk properties (to be discussed).
Details of Changes
Add the VolumeInfo structure and its asynchronous factory which uses FullTrust code to retrieve the information.
This VolumeInfo is not yet used but will be used later to store folder sizes between sessions.
Validation
How did you test these changes?