예제 #1
0
        internal async Task <bool> OpenFolder()
        {
            folder = await StorageService.RequestFolderAsync(new StorageDialogSettings());

            if (folder != null)
            {
                var items = (await folder.GetItemsAsync()).ToArray();
                FileList.Clear();
                FileList.AddRange(items.OfType <IStorageFile>()
                                  .Where(i => i.FileType == ".cco")
                                  .Select(f => f.GetNameWithoutExtension())
                                  .ToArray());
                if (await folder.ContainsItemAsync("Microcode.mco"))
                {
                    var mFile = await folder.GetFileAsync("Microcode.mco");

                    Configuration.MicrocodeFile = await mFile.ReadTextAsync();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        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)));
            }
        }
예제 #3
0
        private void UpdateData()
        {
            FilePath = this.model.FilePath;

            FileList.Clear();
            FileList.AddRange(this.model.FileList);

            SelectedFile = FileList.FirstOrDefault();
        }
예제 #4
0
        static void Main(string[] args)
        {
            List <string>    AllFiles = new List <string>();
            List <FileSizes> SizeList = new List <FileSizes>();


            void ParsePath(string path, List <string> FileList)
            {
                try
                {
                    string[] SubDirs = Directory.GetDirectories(path);
                    FileList.AddRange(SubDirs);
                    FileList.AddRange(Directory.GetFiles(path));
                    foreach (string subdir in SubDirs)
                    {
                        ParsePath(subdir, FileList);
                    }
                } catch (UnauthorizedAccessException exc)
                {
                    Console.WriteLine("Acceso no autorizado; " + path);
                }
            }

            ParsePath(@"C:\", AllFiles); // C:\Users\raymu\AppData       D:\Banxico
            FileInfo info;
            long     media = 0;

            foreach (string entry in AllFiles)
            {
                info = new FileInfo(entry);
                if ((info.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    // Console.WriteLine("Directorio - " + entry);
                }
                else
                {
                    media += info.Length;
                    long size = info.Length / (1024 * 1024);
                    SizeList.Add(new FileSizes(size, entry));
                }
            }
            Console.WriteLine("# Files: " + SizeList.Count.ToString() + ", Tamaño medio: " + media / SizeList.Count + " bytes");;
            Console.WriteLine(SizeList.Count.ToString());
            foreach (FileSizes item in SizeList)
            {
                if (item.size > 100)
                {
                    Console.WriteLine(item.size.ToString() + " MB - " + item.path);
                }
            }
            Console.WriteLine("# Files: " + SizeList.Count.ToString() + ", Tamaño medio: " + media / SizeList.Count + " bytes");
            Console.WriteLine("FIN");
            Console.ReadKey();
        }
        private string BuildFileChangeOutput()
        {
            if (!UncommitedFiles.Any())
            {
                return(String.Join(Environment.NewLine, FileList));
            }

            FileList.Add(String.Empty);
            FileList.Add("Untracked/Uncommited Files:");
            FileList.Add(String.Empty);
            FileList.AddRange(UncommitedFiles);
            return(String.Join(Environment.NewLine, FileList));
        }
예제 #6
0
        private void AddFile()
        {
            var a = new Microsoft.Win32.OpenFileDialog()
            {
                Multiselect = true,
                Title       = "Add File"
            };

            if (a.ShowDialog() == true)
            {
                FileList.AddRange(a.FileNames);
            }
        }
예제 #7
0
 public void AddRange(IEnumerable <string> fileList)
 {
     FileList.AddRange(fileList);
 }