The main difference is the API set these functions use.
<stdio.h>
contains the file APIs of the standard C library, <fileapi.h>
is the Win32 APIs. There are also C++ APIs (<iostream>
) which you could use.
I've found that whatever API you use, you should explicitly set the file location to the Local folder.
Platform::String^ localfolder = Windows::Storage::ApplicationData::Current->LocalFolder->Path;
Platform::String^ myFileName = Platform::String::Concat(localfolder, "\\myfile.txt");
One thing to watch is that Platform::String^
uses wchar_t
, not char
internally so you need to be a bit careful in specifying the file name.
So, try and find an API that takes wchar_t*
for the file name and use that to avoid having to do character set conversion.
E.g.: Use _wfsopen
instead of fopen
.