2016-05-16 135 views
-1

我有以下代码:UWP - 图片库 - 访问被拒绝

FileSavePicker savePicker = new FileSavePicker(); 
savePicker.FileTypeChoices.Add("Plain Text", new List<string>() { ".txt" }); 
savePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; 
savePicker.SuggestedFileName = "New Document"; 
savePicker.SuggestedSaveFile = photo; 
await savePicker.PickSaveFileAsync(); 

和我appxmanifest样子:

<?xml version="1.0" encoding="utf-8"?> 
<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" IgnorableNamespaces="uap mp"> 
    <Identity Name="" Publisher="" Version="1.0.0.0" /> 
    <mp:PhoneIdentity PhoneProductId="" PhonePublisherId="00000000-0000-0000-0000-000000000000" /> 
    <Properties> 
    <DisplayName></DisplayName> 
    <PublisherDisplayName></PublisherDisplayName> 
    <Logo>Assets\StoreLogo.png</Logo> 
    </Properties> 
    <Dependencies> 
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" /> 
    </Dependencies> 
    <Resources> 
    <Resource Language="x-generate" /> 
    </Resources> 
    <Applications> 
    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="zalegaNaMagazynie.App"> 
     <uap:VisualElements DisplayName="" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="" BackgroundColor="transparent"> 
     <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"> 
     </uap:DefaultTile> 
     <uap:SplashScreen Image="Assets\SplashScreen.png" /> 
     </uap:VisualElements> 
    </Application> 
    </Applications> 
    <Capabilities> 
    <Capability Name="internetClient" /> 
    <uap:Capability Name="picturesLibrary" /> 
    <uap:Capability Name="removableStorage" /> 
    <DeviceCapability Name="webcam" /> 
    </Capabilities> 
</Package> 

但我总是得到一个“访问被拒绝”的错误,当我”调试。 我在拍摄照片后使用了C#代码,因为我需要将其转换为Base64,并且我得到了一些教程,我必须先保存图像,然后使用流等,或者您有更好的解决方案来转换图像到Base64。我需要Base64通过使用HttpClient的POST方法将图片发送到Web API。

+0

Hi @Pawel,欢迎来到StackOverflow!为了帮助S.O.用户,你的问题的清晰度很重要。我相信除了“访问被拒绝”错误之外,你还需要做几件事情。请编辑您的问题并将其分解。如果您可以指定迄今已尝试过的解决方案,它也将有所帮助。干杯! –

回答

0

您可以将文件保存在本地文件夹中。它不需要任何清单中的功能。

StorageFile sf = await ApplicationData.Current.LocalFolder.CreateFileAsync("filename.txt"); 

顺便说一句如果你想发送小文件HttpClient可以使用。不推荐大数据