0

I'm trying to copy a StorageFile to StorageFolder

StorageFile timeStampFile = timeStampFiles.First(f => f.Name == sourceFile.Name);

Debug.WriteLine("TS FILE DATE=" + timeStampFile.DateCreated.DateTime); 
//TS FILE DATE=9/6/2018 7:14:43 PM

StorageFile createdCopy = await timeStampFile.CopyAsync(destinationFolder);
Debug.WriteLine("COPIED FILE DATE=" + createdCopy.DateCreated.DateTime);
//COPIED FILE DATE=9/6/2018 7:36:30 PM

But DateCreated.DateTime of the created copy is different from the original file. How can I copy file with same DateCreated.DateTime info?

alperen
  • 3
  • 3
  • You are copying the file. i.e, Creating a copy of the file from another folder. That is the reason why date created is different. Try [Move](https://learn.microsoft.com/en-us/uwp/api/windows.storage.storagefile.moveasync) or [MoveAndReplace](https://learn.microsoft.com/en-us/uwp/api/windows.storage.storagefile.moveandreplaceasync). – AVK Sep 06 '18 at 17:32
  • Call [SetFileTime](https://learn.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-setfiletime) to set the desired value. This [Q&A](https://stackoverflow.com/q/42799235/1889329) tells you, how to get a file handle from a `StorageFile`. – IInspectable Sep 06 '18 at 19:57

0 Answers0