コード例 #1
0
        public void ChildsAdd(VFile file)
        {
            string name = file.FileName;
            VFile  cp   = this.FindInChilds(name);

            if (cp != null)
            {
                int i = 0;
                while (cp != null)
                {
                    i++;
                    // Думал вот сейчас напишешь одну строчку, а фот фиг тебе, експешен кидает на кривые пути(
                    // name = Path.GetFileNameWithoutExtension(file.FileName) + "(" + i.ToString() + ")" + Path.GetExtension(file.FileName);
                    int dotPos = file.FileName.LastIndexOf('.');
                    if (dotPos > -1)
                    {
                        name = file.FileName.Substring(0, dotPos) + "(" + i.ToString() + ")" + file.FileName.Substring(dotPos);
                    }
                    else
                    {
                        name = file.FileName + "(" + i.ToString() + ")";
                    }

                    cp = this.FindInChilds(name);
                }
                file.FileName = name;
            }

            Childs.Add(file);
        }
コード例 #2
0
ファイル: VFile.cs プロジェクト: DnAp/VKDrive
 public void CopyTo(VFile finfo)
 {
     finfo.Attributes     = Attributes;
     finfo.CreationTime   = CreationTime;
     finfo.FileName       = FileName;
     finfo.LastAccessTime = LastAccessTime;
     finfo.LastWriteTime  = LastWriteTime;
     finfo.Length         = Length;
 }
コード例 #3
0
ファイル: VFile.cs プロジェクト: DnAp/VKDrive
 public static FileInformation Cast(VFile vFile)
 {
     return(new FileInformation()
     {
         Attributes = vFile.Attributes,
         CreationTime = vFile.CreationTime,
         FileName = vFile.FileName,
         LastAccessTime = vFile.LastAccessTime,
         LastWriteTime = vFile.LastWriteTime,
         Length = vFile.Length
     });
 }
コード例 #4
0
        private void GroupFile()
        {
            if (Childs.Count <= 500)
            {
                return;
            }
            const int maxFile = 500;

            /*if (Childs.First().GetType() == typeof(Folder))
             * {
             *  maxFile = 100;
             * }
             * else if (Childs.Count < maxFile)
             * {
             *  return;
             * }*/

            BlockingList <VFile> replaceChilds = new BlockingList <VFile>();
            List <VFile>         copy          = Childs.Select(item => item).ToList(); // clone list

            copy.Sort((a, b) => string.Compare(a.FileName, b.FileName, StringComparison.Ordinal));
            for (var i = 0; i <= (copy.Count / maxFile); i++)
            {
                var residue = copy.Count - (i * maxFile);         // остаток
                residue = residue < maxFile ? residue : maxFile;
                IList <VFile> tmp        = copy.GetRange(i * maxFile, residue);
                var           folderName = VFile.ClearName(tmp[0].FileName, false).Substring(0, 1) + ".." + VFile.ClearName(tmp[residue - 1].FileName, false).Substring(0, 1);
                var           fNode      = new Folder(folderName);

                foreach (VFile curFile in tmp)
                {
                    fNode.Childs.Add(curFile);
                }
                fNode.IsLoaded = true;
                replaceChilds.Add(fNode);
            }
            Childs = replaceChilds;
        }