Hi all,

I need to set Creation Time on a newly created file before I close this file. I use FileStream to create the files.

In C++/Win32 programming, I can say

HANDLE hFile = CreateFile(...);
WriteFile( hFile, ...);
SetFileTime( hFile, ....);
CloseHandle( hFile );

However, in .NET, I can't seem to call File.SetCreationTime on a file until I close the FileStream. I get the error "The process cannot access the file ... because it is being used by another process."

Unfortunately I can't close the file and then set the Creation Time because another process (a service running in the background) may snatch the file from the folder right after it's closed but before I have the chance to change its Creation Time.

Any way to do it in .NET?

Thanks in advance

DC Dweller