Skip to content

Commit cdc760b

Browse files
committed
Ensure dates are copied before deleting the .mp4
1 parent ebf1626 commit cdc760b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

FlickrDownloaderApp.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,10 @@ private static void MergeVideos()
131131
}
132132
string mp4File = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(path)));
133133
FileInfo oldInfo = new FileInfo(mp4File);
134+
DateTime oldWriteTime = oldInfo.LastWriteTimeUtc;
135+
DateTime oldCreationTime = oldInfo.CreationTimeUtc;
134136
string newFile = Path.Combine(Path.GetDirectoryName(path), Path.GetFileName(file));
135-
if (File.Exists(newFile))
136-
{
137-
File.Delete(newFile);
138-
}
137+
139138
// delete the txt file and mp4 file
140139
if (File.Exists(path))
141140
{
@@ -145,12 +144,18 @@ private static void MergeVideos()
145144
{
146145
File.Delete(mp4File);
147146
}
147+
148+
// move the video over
149+
if (File.Exists(newFile))
150+
{
151+
File.Delete(newFile);
152+
}
148153
File.Move(file, newFile);
149154

150155
// copy over dates
151156
FileInfo info = new FileInfo(newFile);
152-
info.LastWriteTimeUtc = oldInfo.LastWriteTimeUtc;
153-
info.CreationTimeUtc = oldInfo.CreationTimeUtc;
157+
info.LastWriteTimeUtc = oldWriteTime;
158+
info.CreationTimeUtc = oldCreationTime;
154159
info.Refresh();
155160

156161
Console.Write("Videos Moved: {0} \r", ++count);

0 commit comments

Comments
 (0)