积极答复者
ms-appx用法?

问题
答案
-
ms-appx 其实是引用了应用发布安装之后的应用的所在目录,所以只要你的项目中的文件Build Action为Content (C++项目为 Content 为 true) 这个文件就会被打包输出到App的发布目录,然后你就可以用ms-appx:///引用。
注意,同一个解决方案中不同的项目的文件输出的Content 是在不同的项目名命名的文件夹下面的,所以你的ms-appx://引用时候注意是否要添加项目名(主项目是不会添加项目名命名的文件夹的)
如果是代码的话,你可以用 Windows.ApplicationModel.Package.Current.InstalledLocation 访问到应用安装根目录。
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
- 已标记为答案 wenzhong86 2012年10月25日 6:56
全部回复
-
// Retrieve the uri of the image and use that to load the file. Uri^ uri = ref new Uri("ms-appx:///assets/110Strawberry.png"); create_task(StorageFile::GetFileFromApplicationUriAsync(uri)).then([] (StorageFile^ file) { // Open a sequential-access stream over the image file. return file->OpenSequentialReadAsync(); }).then( // Since this is the last task in the chain, use task<IInputStream ^> instead of IInputStream ^ // as the parameter here in order to handle any exceptions which might have been thrown in // the previous async calls. [=] (task<IInputStream ^> inputStream) { try { currChunk = 0; ReadBytesOutput->Text = ""; // Use inputStream.get() to pass the input stream returned by OpenSequentialReadAsync() to the // DataReader, or to catch any exceptions that might have arisen in the chained async calls. DataReader^ dataReader = ref new DataReader(inputStream.get()); // Read and process the data contained in the input stream. ReadLoop(dataReader); } catch (Exception^ e) { ReadBytesOutput->Text = e->Message; } });
我认为这些代码可以帮助你。 -
ms-appx 其实是引用了应用发布安装之后的应用的所在目录,所以只要你的项目中的文件Build Action为Content (C++项目为 Content 为 true) 这个文件就会被打包输出到App的发布目录,然后你就可以用ms-appx:///引用。
注意,同一个解决方案中不同的项目的文件输出的Content 是在不同的项目名命名的文件夹下面的,所以你的ms-appx://引用时候注意是否要添加项目名(主项目是不会添加项目名命名的文件夹的)
如果是代码的话,你可以用 Windows.ApplicationModel.Package.Current.InstalledLocation 访问到应用安装根目录。
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
- 已标记为答案 wenzhong86 2012年10月25日 6:56