Reputation: 4109
I need to generate the unique temporary filenames in my application using c++ (WINRT/Metro). As I see, Win32 API GetTempFileName
is marked for use on desktop only.
What is its equivalent for metro style apps?
Upvotes: 4
Views: 498
Reputation: 513
Yo can achieve this by saving a file in temporary storage, and naming them via a GUID. Example:
// Get temporary storage folder
var tempFolder = Windows.Storage.ApplicationData.Current.TemporaryFolder;
// generate unique filename
var filename = Guid.NewGuid().ToString();
StorageFile myFile = await tempFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
Upvotes: 1