Friday, April 13, 2012 4:07 AM
Could I be authorized to write file in Metro Apps using Win32 API "WriteFile"(It should be used in Metro Apps according to the MSDN 's description)?
if it did,how to get the absolute path of the file which is in document library(yes , i know the file must be here and i have to declare something in manifest at first)?
Friday, April 13, 2012 8:50 AMModerator
First, I suggest you to follow up this sample codes
You need to set the manifest.
To enable access the document folder:
Double click the Package.appxmanifest->Capabilites->Select Documents Library
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
Friday, April 13, 2012 3:06 PMModerator
No, you cannot use WriteFile (or other Win32 file functions) for files in the Documents library. Your app does not have access to that location and cannot read or write from it directly. The app can directly access only the locations natively accessible to the app: files and folders within the app's local storage and install dir.
Access to other locations such as the Documents Library is provided via a broker process. If your app has the appropriate capabilities and declarations (Document Library capability and file type association for files in the Documents Library) then it can request these files through the WinRT StorageFile and StorageFolder classes. The broker process will then open the files on your behalf and provide a stream with their contents.
Using files: accessing, searching, and acting on files should give more details on how this works.
Saturday, April 14, 2012 12:32 AM
Howerver,why can't I open the file in app dir with writing right using writefile api? And what would the correcting paramters be passed in writingfile api?
Saturday, April 14, 2012 3:48 AMOnly read acces to app InstalledLocation (APPX) and R/W access to App's Data Path
Monday, April 16, 2012 1:40 AMAnd how can I get the path of APPX which would be passed into writefile api as parameter?
Monday, April 16, 2012 2:26 AMModerator
What is your specific use case here? If you explain what you want to do then we can provide better suggestions.
Is there a reason you want to use WriteFile instead of Windows.Storage? While you can use CreateFile2/WriteFile, it's not generally going to be easier than or as powerful as using the Windows Runtime classes.
Monday, April 16, 2012 3:16 AM
Some legacy lib need to be ported to WinRT, and they do not support multithread operation.
Monday, April 16, 2012 3:17 AMIStorageItem.Path is what you need.