locked
How to get an application's current path in metro app? RRS feed

  • Question

  • i need to know where metro app located each time it starts. how?
    Sunday, August 5, 2012 4:57 PM

Answers

  • string path = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;

    Should give you exactly what you're looking for.
    • Proposed as answer by Carl Jantzen Sunday, August 5, 2012 4:59 PM
    • Marked as answer by fmastyaev Sunday, August 5, 2012 5:23 PM
    Sunday, August 5, 2012 4:59 PM

All replies

  • string path = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;

    Should give you exactly what you're looking for.
    • Proposed as answer by Carl Jantzen Sunday, August 5, 2012 4:59 PM
    • Marked as answer by fmastyaev Sunday, August 5, 2012 5:23 PM
    Sunday, August 5, 2012 4:59 PM
  • Thanks Carl Jantzen !

    I get an application's current path in metro app by c++

     

    char

    * AppPath_char = newchar[255];

    auto AppPath =

    Windows::ApplicationModel::

    Package::Current->InstalledLocation;

    intcb = WideCharToMultiByte(CP_UTF8,0,AppPath->Path->Data(),-1,nullptr,0,nullptr,nullptr);

    char* sz = newchar[cb];

    if(WideCharToMultiByte(CP_UTF8,0,AppPath->Path->Data(),-1,sz,cb,nullptr,nullptr) > 0)

            strcpy(AppPath_char ,sz);

    //do somthings with path  AppPath_char

    delete sz;

     

     




    • Edited by ldhung Friday, August 10, 2012 2:45 AM
    Friday, August 10, 2012 2:40 AM