Dear Colleagues,

when using the _wfopen_s( ... ) function, you might need to pass the file name to that


If you pass a string constant ( e.g. "C:\\Directory\\File.ext" ), the function takes it with no


But if you pass a variable that gets assigned the same string, you get a run time error of

an assertion type. Then even you succeed to satisfy the file name requirement by casting the

formal parameter type, you start getting another error - "wrong file open mode".

After trying all the ANSI, UNICODE, UTF-8/16LE, the result is still the same - run time error.

Also, whatever "errno" variable says doesn't help at all.

So, what arguments needs this function exactly

If we assume the wide character symbols are allocated in a separate heap ( like run time

allocations ), we can probably copy these strings into regular ones and then pass them - that

doesn't work, as well ...

Thanks everybody for their future assistance !

Re: Visual C++ Language New style file open functions.


I take it you're using WCHARs as the string you pass in If you're just using chars that's why it fails. _wfopen_s is the wide char version of fopen_s. You could also use _tfopen_s for TCHARs. If this is the mistake you are making, investigate wide chars and tchars carefully. Until you have a good understanding of them use fopen_s and normal chars.

Hope that's of some help,


Re: Visual C++ Language New style file open functions.


Thanks a lot !