I need to set file creation time after I download it using sockets. In CF FileInfo.CreationTime is readonly. I tried to use P/Invoke solution from this topic, but it won’t work: I get error 6 (Invalid handle).
According to MSDN first parameter for SetFileTime() must be a handle, while in the topic mentioned it is string, and somebody says that it works for him. What am I doing wrong? If I need to use handle, how can I get this handle in CF and how should I change SetFileTime() declaration?
Interesting. The answer you point to is obviously wrong, though it was accepted.
At any rate, you need to pass in a HANDLE (IntPtr or however you’d like to represent it) that is returned from a call to CreateFile – which you’ll also need to P/Invoke.
Be sure to call CloseHandle when you’re done.