Esempio n. 1
0
        private void f_BeforeFileCopy(object sender, CBeforeFileCopyEventArgs e)
        {
            FileInfo fiSrc  = new FileInfo(e.FullPathSrc);
            FileInfo fiDest = (File.Exists(e.FullPathDest) ? new FileInfo(e.FullPathDest) : null);

            if (fiDest != null)
            {
                //Remove ReadOnly attribute from destination to block error when copying.
                if ((fiDest.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                {
                    FileAttributes AttrRemoved = CFile.RemoveAttribute(fiDest.Attributes, FileAttributes.ReadOnly);
                    fiDest.Attributes = AttrRemoved;
                }
            }

            string FullPathSrcNewIs;

            if (!IsValidForSync(fiSrc, fiDest, false, out FullPathSrcNewIs))
            {
                e.Cancel = true;
            }

            if (!string.IsNullOrEmpty(FullPathSrcNewIs))
            {
                e.FullPathSrcNew = FullPathSrcNewIs;
            }
        }