第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

在 UWP 的 DriveInfo 中訪問(wèn) AvailableFreeSpace/TotalSize

在 UWP 的 DriveInfo 中訪問(wèn) AvailableFreeSpace/TotalSize

C#
偶然的你 2022-01-09 17:10:08
我可以使用 DriveInfo.GetDrives() 方法列出本地磁盤(pán)。另外,我使用 Name 屬性訪問(wèn)/獲取驅(qū)動(dòng)器名稱。但我收到錯(cuò)誤為“系統(tǒng)。未經(jīng)授權(quán)的訪問(wèn)異常:'訪問(wèn)路徑'X:\'被拒絕?!?在訪問(wèn)諸如 AvailableFreeSpace 之類(lèi)的任何屬性時(shí)。代碼如下。DriveInfo[] allDrives = DriveInfo.GetDrives();foreach (DriveInfo d in allDrives){   Debug.WriteLine("Drive: " + d.Name); //This line executes w/o error!   Debug.WriteLine("Drive: " + d.AvailableFreeSpace);   Debug.WriteLine("Drive: " + d.TotalSize);}注意:我在 Package Tag Block 和 <rescap:Capability Name="broadFileSystemAccess"/> 中放置了以下行 xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"我項(xiàng)目的 Package.appxmanifest 文件中的功能標(biāo)記塊。
查看完整描述

1 回答

?
倚天杖

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊

我可以使用以下代碼為我的一些驅(qū)動(dòng)器獲取總的可用磁盤(pán)空間:


        const String k_freeSpace = "System.FreeSpace";

        const String k_totalSpace = "System.Capacity";

        DriveInfo[] allDrives = DriveInfo.GetDrives();

        foreach (DriveInfo d in allDrives)

        {

            try

            {

                Debug.WriteLine("Drive: " + d.Name);

                Debug.WriteLine("RootDir: " + d.RootDirectory.FullName);


                StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(d.RootDirectory.FullName);

                var props = await folder.Properties.RetrievePropertiesAsync(new string[] { k_freeSpace, k_totalSpace });

                Debug.WriteLine("FreeSpace: " + (UInt64)props[k_freeSpace]);

                Debug.WriteLine("Capacity:  " + (UInt64)props[k_totalSpace]);

            }

            catch (Exception ex)

            {

                Debug.WriteLine(String.Format("Couldn't get info for drive {0}.  Does it have media in it?", d.Name));

            }

        }

我的“最低版本”和“目標(biāo)版本”都針對(duì) Windows 10 版本 1803(10.0:Build 17134)。


以下是我的 Package.appxmanifest 的一些摘錄


<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" 

         xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" 

         xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" 

        xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10" 

        xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" 

        IgnorableNamespaces="uap mp iot rescap">

...


<Capabilities>

    <Capability Name="internetClient" />

    <rescap:Capability Name="broadFileSystemAccess" />

  </Capabilities>

</Package>


查看完整回答
反對(duì) 回復(fù) 2022-01-09
  • 1 回答
  • 0 關(guān)注
  • 176 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)