login about faq

I need to copy files from windows to a UNIX server, and I am able to do so using UploadFileByName, but the LastModifiedTime is set to (Now) instead of keeping the original file's LastModifiedTime.

When I use a WinSCP, the LastModifiedTime is reatined.


Thanks for your time

asked May 09 '14 at 15:24

ResidentofTheLand's gravatar image


Here is what I am doing. File dates of existing files are stomped.

Get Photos from directory

$CurrentPhotos = $Photos | where {$_.Directory.FullName -eq $WindowsCurrentDir}

If there are photos

if($CurrentPhotos -ne $null) { # For Each Photo in directory foreach($CurrentPhoto in $CurrentPhotos) { # Start with Forced Copy - this will be replaced with "If File Newer" $remoteFilePath = $UNIXCurrentDir + "/" + $CurrentPhoto.Name $success = $sftp.UploadFileByName($remoteFilePath,$CurrentPhoto.FullName) } }

(May 09 '14 at 16:30) ResidentofTheLand

I think the last-modified time should be maintained. Maybe you're using an older version? Chilkat uses it's own products internally, especially the SFTP functionality for synchronizing local directory trees with remote directory trees -- which wouldn't work unless last-mod times were maintained (and I use this functionality daily with many servers..)


answered May 09 '14 at 15:53

chilkat's gravatar image

chilkat ♦♦

Nevermind, I just failed at reading comprehension and assumed the OP was replacing files that already existed on the server, not uploading new files.

(May 09 '14 at 16:01) jpbro ♦

This is fixed in v9.5.0.40.

The PreserveDate property now affects both uploads and downloads. Starting in v9.5.0.40, the UploadFileByName method will preserve the last-mod date/time for the file that is uploaded.

Note: The SyncTreeUpload/Download methods already preserve the last-mod date/times regardless of the PreserveDate property setting.

Please let me know the exact build you require (programming language, operating system, etc.) and I will provide a pre-release..


answered May 12 '14 at 12:34

chilkat's gravatar image

chilkat ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: May 09 '14 at 15:24

Seen: 952 times

Last updated: May 12 '14 at 12:34

powered by OSQA