예제 #1
0
 public static bool FileExists(string path)
 {
     try
     {
         if (Settings.Data[2] == "0") // game
         {
             return(FileList.Contains(path.Replace(@"\"[0], @"/"[0])));
         }
         else if (Settings.Data[2] == "1") // online
         {
             /* ??? */
         }
         else if (Settings.Data[2] == "2") // extracted
         {
             bool exists = File.Exists(Settings.Data[8] + @"\" + path);
             return(exists);
         }
         return(false);
     }
     catch
     {
         Debug.Log("CASC Error: Can't check if the file exists.");
         return(false);
     }
 }
        /// <summary>
        /// 添加单个文件
        /// </summary>
        /// <param name="path"></param>
        private void _addOne(string path)
        {
            var item = new FileItem(path);

            if (FileList.Contains(item))
            {
                return;
            }
            FileList.Add(item);
        }
예제 #3
0
 public bool Add(string newFilePath)
 {
     if (System.IO.File.Exists(newFilePath) && Path.GetExtension(newFilePath).IsInputType() &&
         !FileList.Contains(newFilePath))
     {
         FileList.Add(newFilePath);
         return(true);
     }
     return(false);
 }
예제 #4
0
파일: program.cs 프로젝트: Mr-knick/Demo
 // Insert logic for processing found files here.
 public static void ProcessFile(string path)
 {
     //Console.WriteLine("Processed file '{0}'.", path);
     if (Path.GetExtension(path) == ".pdf")
     {
         if (!FileList.Contains(path))
         {
             FileList.Add(path);
         }
     }
 }
        public void Testv2()
        {
            DirectoryInfo root = new DirectoryInfo(BaseDirectory);

            FileList files = new FileList();

            files.AddRange(root.GetFiles("*", SearchOption.AllDirectories));
            Assert.AreEqual(7, files.Count);

            FileList txtFiles = new FileList(root.GetFiles("*.txt", SearchOption.AllDirectories));

            Assert.AreEqual(3, txtFiles.Count);
            Assert.IsTrue(files.Contains(txtFiles[0]));
            Assert.IsTrue(files.Contains(txtFiles[1]));
            Assert.IsTrue(files.Contains(txtFiles[2]));

            files.Remove(txtFiles.ToArray());
            Assert.AreEqual(4, files.Count);
            Assert.IsFalse(files.Contains(txtFiles[0]));
            Assert.IsFalse(files.Contains(txtFiles[1]));

            string[] names = files.GetFileNames();
            Assert.AreEqual(4, names.Length);
            foreach (string fpath in names)
            {
                Assert.IsTrue(files.Contains(new FileInfo(fpath)));
            }
        }
예제 #6
0
        public void AddFile(IFile file)
        {
            if (file == null)
            {
                return;
            }

            if (!FileList.Contains(file.GetType().Name))
            {
                FileList.Add(file.GetType().Name);
            }

            Files.Add(file);
        }
예제 #7
0
 public virtual void AddFile(DtoFileInfo dtoFileInfo)
 {
     lock (this)
     {
         if (FileList != null && FileList.Contains(dtoFileInfo))
         {
             return;
         }
         if (FileList == null)
         {
             FileList = new List <DtoFileInfo>();
         }
         FileList.Add(dtoFileInfo);
         dtoFileInfo.Log = this;
     }
 }
예제 #8
0
 public static bool FileExists(string path)
 {
     if (Settings.Data[2] == "0") // game
     {
         return(FileList.Contains(path.Replace(@"\"[0], @"/"[0])));
     }
     else if (Settings.Data[2] == "1") // online
     {
         /* ??? */
     }
     else if (Settings.Data[2] == "2") // extracted
     {
         bool exists = File.Exists(Settings.Data[8] + @"\" + path);
         return(exists);
     }
     return(false);
 }
예제 #9
0
        internal Task <int> Scan()
        {
            return(Task.Run <int>(() =>
            {
                int newFiles = 0;
                foreach (var file in Directory.EnumerateFiles(RootPath, "*", SearchOption.AllDirectories))
                {
                    var relativeFile = PathEx.GetRelativePath(RootPath, file);
                    if (relativeFile.StartsWith(".kai"))
                    {
                        continue;
                    }
                    if (!FileList.Contains(relativeFile))
                    {
                        FileList.Add(relativeFile);
                        newFiles++;
                    }
                }

                return newFiles;
            }));
        }
예제 #10
0
        private void DropEventHandler(object sender, DragEventArgs e)
        {
            if (!AllowDragDrop)
            {
                return;
            }
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                var files = GetAvailableFiles(e.Data.GetData(DataFormats.FileDrop) as string[]);
                if (files.Length == 0)
                {
                    return;
                }
                foreach (var file in files)
                {
                    if (!FileList.Contains(file))
                    {
                        FileList.Add(file);
                    }
                }

                FileDropped?.Invoke(this, new Common.StorageOperationEventArgs(files.ToArray()));
            }
        }
예제 #11
0
 public bool Contains(string checkValue)
 {
     return(FileList.Contains(checkValue));
 }