But the problem is you can't open a file. It has nothing to do with the clipboard.
Printable View
Please, don't disturb, if you have some answer, tell me, but if not, please, don't change the subject.
Thank you
I'm trying to help you get information. If you're looking for information on how to open a file and you post a subject about the clipboard that has nothing to do with your question, people that may know about files but not the clipboard may skip your thread.
I showed you MSDN's information on how to find a detailed error message. Did you try it yet?
Yes, I did. I used this funtion
http://cplusplus.com/forum/windows/2068/
And the result was:
It can't open the file failed with error 0: The operation was complete rightly
Why did you ignore what GCDEF wrote you:
Why did you ignore what MSDN claims in fopen, _wfopen article::confused:Quote:
Return Value
Each of these functions returns a pointer to the open file. A null pointer value indicates an error. If filename or mode is NULL or an empty string, these functions trigger the invalid parameter handler, which is described in Parameter Validation. If execution is allowed to continue, these functions return NULL and set errno to EINVAL.
For more information, see errno, _doserrno, _sys_errlist, and _sys_nerr.
You can't simply use a file name if you expect to find a file in the virtual store folder. This assumes that your current directory is already set to the virtual store folder which is probably not a good assumption. An effective solution might use the ::SHGetSpecialFolderPath() API function like this:
Now, to find the full path of a file called "temporal.dat" you would do this:Code:CString VirtualStoreFilePath(LPCTSTR fileName)
{
CString path;
LPTSTR buffer = path.GetBuffer(MAX_PATH);
if(::SHGetSpecialFolderPath(0, buffer, CSIDL_LOCAL_APPDATA, FALSE))
{
VERIFY(::PathAppend(buffer, _T("VirtualStore")));
VERIFY(::PathAppend(buffer, fileName));
}
path.ReleaseBuffer();
return path;
}
This should work on any computer / Windows OS that implements the VirtualStore folder. However, the function I have shown is very basic and does only minimal error checking. A real program would only use this as a starting point to build a more reliable application. You should note that this function may return an empty string so you would need to determine why.Code:CString fullPath = VirtualStoreFilePath(_T("temporal.dat"));
fichero= fopen(fullPath,"wb");
Also, note that this function will return the full path of a file assumed to be located in the virtual store but it absolutely does not guarantee that the file exists. In fact, the virtual store root folder typically does not contain individual files but instead subfolders named after applications that use it. With that in mind, you may have to use the function like this:
Code:CString fullPath = VirtualStoreFilePath(_T("MyAppName\\temporal.dat"));
fichero= fopen(fullPath,"wb");
Thank you so much, I used the first option becouse I didnt understand very good the second and everything run perfectly.
In the second option, MyAppName is the name of my aplication, I suposse, but I wrote
CString fullPath = VirtualStoreFilePath(_T("Adest\\temporal.dat"));
fichero= fopen(fullPath,"wb");
and it couldn't open the file