Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, August 16, 2018 9:33 AM
Hi all,
I must use the code page 936, the StorageFile class can't support code page 936. The StreamReader class can only open the file under the current folder but can't open the file which is under "c:\Data\USERS\Public\ folder (Access to the path 'c:\Data\USERS\Public\readme.txt' is denied.), how to fix this?
<Capabilities>
<Capability Name="internetClientServer" />
<Capability Name="privateNetworkClientServer" />
<uap:Capability Name="musicLibrary" />
<uap:Capability Name="picturesLibrary" />
<uap:Capability Name="videosLibrary" />
<uap:Capability Name="removableStorage" />
<uap:Capability Name="enterpriseAuthentication" />
<rescap:Capability Name="broadFileSystemAccess" />
</Capabilities>
Best regards.
All replies (3)
Wednesday, November 14, 2018 9:59 AM âś…Answered
There must be set the APPX Folder Permissions before use the StreamReader API.
The code works fine now. I test this on the v10.0.17763.107.
Command> folderpermissions c:\data\users\public -e
APPX Folder Permissions
Setting APPX R/W Permissions on folder c:\data\users\public
Success - APPX R/W Permissions now set on folder c:\data\users\public
Thursday, August 16, 2018 9:38 AM
EncodingProvider provider = CodePagesEncodingProvider.Instance;
Encoding.RegisterProvider(provider);
Encoding e = Encoding.GetEncoding(936);
string filePath = @"TextFile1ansi.txt";
StreamReader readFile = new StreamReader(filePath, e);//OK!
string content = readFile.ReadLine();//OK!
string filePath4 = @"c:\Data\USERS\Public\readme.txt";
StreamReader readFile2 = new StreamReader(filePath4,e);//Access denied!
string content2 = readFile2.ReadLine();
Friday, August 17, 2018 5:31 AM | 1 vote
Hello moyanming,
I have tested this issue on winodws iot core. The app also show the same error. I also checked this issue on uwp desktop, but it works fine on desktop.
I have posted this issue via Feedback Hub app. The short link is https://aka.ms/AA22dxu.
Best Regards,
Michael
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].