public static void GetFileProperties(string path, out DateTimeOffset?creationTime, out DateTimeOffset?lastWriteTime, out FileAttributes?fileAttributes
#if DOTNET5_4
                                             , bool isDirectory = false
#endif
                                             )
        {
#if DOTNET5_4
            LongPathFile.GetFileProperties(path, out creationTime, out lastWriteTime, out fileAttributes, isDirectory);
#else
            LongPathFile.GetFileProperties(path, out creationTime, out lastWriteTime, out fileAttributes);
#endif
        }
コード例 #2
0
        private void SetChunkFinish()
        {
            if (1 == Interlocked.Read(ref this.readCompleted))
            {
                if (0 == Interlocked.Exchange(ref this.setCompletionDone, 1))
                {
                    this.state = State.Finished;
                    if (!this.md5HashStream.SucceededSeparateMd5Calculator)
                    {
                        return;
                    }

                    var md5 = this.md5HashStream.MD5HashTransformFinalBlock();
                    this.CloseOwnStream();

                    Attributes attributes = new Attributes()
                    {
                        ContentMD5   = md5,
                        OverWriteAll = false
                    };

                    if (this.transferJob.Transfer.PreserveSMBAttributes)
                    {
                        if (!string.IsNullOrEmpty(this.filePath))
                        {
                            DateTimeOffset?creationTime;
                            DateTimeOffset?lastWriteTime;
                            FileAttributes?fileAttributes;

                            LongPathFile.GetFileProperties(this.filePath, out creationTime, out lastWriteTime, out fileAttributes);

                            attributes.CloudFileNtfsAttributes = Utils.LocalAttributesToAzureFileNtfsAttributes(fileAttributes.Value);
                            attributes.CreationTime            = creationTime;
                            attributes.LastWriteTime           = lastWriteTime;
                        }
                    }

                    if (PreserveSMBPermissions.None != this.transferJob.Transfer.PreserveSMBPermissions)
                    {
                        if (!string.IsNullOrEmpty(this.filePath))
                        {
                            attributes.PortableSDDL = FileSecurityOperations.GetFilePortableSDDL(filePath, this.transferJob.Transfer.PreserveSMBPermissions);
                        }
                    }

                    this.SharedTransferData.Attributes = attributes;
                }
            }
        }
        public static void GetFileProperties(string path, out DateTimeOffset?creationTime, out DateTimeOffset?lastWriteTime, out FileAttributes?fileAttributes
#if DOTNET5_4
                                             , bool isDirectory = false
#endif
                                             )
        {
            try
            {
                path = DMLibTestConstants.SupportUNCPath ?
                       LongPath.GetFullPath(LongPath.ToUncPath(path)) :
                       LongPath.GetFullPath(path);
            }
            catch (Exception)
            { }

#if DOTNET5_4
            LongPathFile.GetFileProperties(path, out creationTime, out lastWriteTime, out fileAttributes, isDirectory);
#else
            LongPathFile.GetFileProperties(path, out creationTime, out lastWriteTime, out fileAttributes);
#endif
        }