Exemplo n.º 1
0
        /// <summary>
        /// Retrieve a file from the server to the client's default folder.
        /// In case the file wasn't modified since last retrieved, it will not be downloaded from the server
        ///   and will not be copied to the client's default folder.
        /// </summary>
        /// <param name="serverFileName">file name, as known in the server's file system.</param>
        /// <param name="currTask">the current executing task.</param>
        /// <returns>true if the file was found on the client's default folder.</returns>
        internal bool CopyToDefaultFolder(string serverFileName, Task currTask)
        {
            Debug.Assert(currTask != null);

            string clientFileName = (serverFileName.Substring(serverFileName.LastIndexOf('\\') + 1));
            string cachedFileName = GetLocalFileName(serverFileName, currTask, false);

            if (!String.IsNullOrEmpty(cachedFileName))
            {
                // if the file was modified since last retrieved, copy it from the client's cache to the client's default folder
                if (HandleFiles.getFileTime(cachedFileName) != HandleFiles.getFileTime(clientFileName))
                {
                    HandleFiles.copy(cachedFileName, clientFileName, true, false);
                }
            }

            return(HandleFiles.isExists(clientFileName));
        }