Temporary file names in WinRT


  • I need to generate the unique temporary filenames in my application. As I see, Win32 API GetTempFileName is marked for use on desktop only.

    What is its equivalent for metro style apps?

    Friday, June 22, 2012 2:57 PM


  • I'm using GUID:
    String^ createGUID(bool forFileName)
      wchar_t guidStr[120];
      GUID* g = 0x00;
      g = new GUID; 
      wchar_t* maskForFN = L"%08x_%04x_%04x_%02x%02x_%02x%02x%02x%02x%02x%02x";
      wchar_t* mask = L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x";
      wchar_t* useMask;
      if( forFileName)
        useMask = maskForFN;
        useMask = mask;
      swprintf( &guidStr[0],useMask,g->Data1,g->Data2,g->Data3,UINT(g->Data4[0]),UINT(g->Data4[1]),UINT(g->Data4[2]),UINT(g->Data4[3]),UINT(g->Data4[4]),UINT(g->Data4[5]),UINT(g->Data4[6]),UINT(g->Data4[7]));
      delete g;
      return ref new String( guidStr);

    • Marked as answer by Nick_Indian Friday, June 22, 2012 5:45 PM
    Friday, June 22, 2012 4:17 PM