示例#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;
        }