Esempio n. 1
0
        private void InitFiles(TreeListNode treeListNode)
        {
            RowItem item = treeListNode.Content as RowItem;

            if (item == null)
            {
                return;
            }
            try
            {
                string[] root = Directory.GetFiles(item.Address);
                foreach (string s in root)
                {
                    TreeListNode node = new TreeListNode()
                    {
                        Content = new RowItem(System.IO.Path.GetFileNameWithoutExtension(s),
                                              System.IO.Path.GetExtension(s), GetFileSize(s), s)
                    };
                    node.IsExpandButtonVisible = DefaultBoolean.False;
                    writeFileBytesOnTheRAM(node);
                    parent_TreeListView.Dispatcher.Invoke(new Action(delegate { treeListNode.Nodes.Add(node); }), System.Windows.Threading.DispatcherPriority.DataBind);
                }
            }
            catch (IOException io) { parent_Window.Dispatcher.Invoke(new Action(delegate { MsgBox.Show(io.Message, io.Source, parent_Window); }), System.Windows.Threading.DispatcherPriority.Render); }
            catch (Exception ex) { parent_Window.Dispatcher.Invoke(new Action(delegate { MsgBox.Show(ex.Message, ex.Source, parent_Window); }), System.Windows.Threading.DispatcherPriority.Render); }
        }
Esempio n. 2
0
        private void writeFileNodesOntheTargetPath(TreeListNode node, string TargetPath)
        {
            RowItem dataRow = node.Content as RowItem;

            //
            // If node is a Folder then create that directory on the target path
            if (dataRow.Data == null && dataRow.Extension == "<Folder>")
            {
                if (!Directory.Exists(TargetPath))
                {
                    Directory.CreateDirectory(TargetPath);
                }
            }
            //
            // Check File Size to select Fat32 or Fat64 Writer (Larger than 2GB)
            // and Read all bytes of file
            else if (dataRow.longSize / 1024 / 1024 / 1024 >= 2) // FAT64 ------------------------------------------
            {
                if (!Directory.Exists(TargetPath))
                {
                    Directory.CreateDirectory(TargetPath);
                }

                using (var file = File.Create(string.Format("{0}\\{1}{2}", TargetPath, dataRow.Name, dataRow.Extension)))
                {
                    long length = dataRow.Data.LongCount();
                    for (long i = 0; i < length; i++)
                    {
                        file.WriteByte(dataRow.Data[i]);
                    }
                }
            }
            else // FAT32 ----------------------------------------------------------------------------------------------
            {
                if (!Directory.Exists(TargetPath))
                {
                    Directory.CreateDirectory(TargetPath);
                }

                using (var file = File.Create(string.Format("{0}\\{1}.{2}", TargetPath, dataRow.Name, dataRow.Extension)))
                {
                    file.Write(dataRow.Data, 0, dataRow.Data.Length);
                }
            }
        }
Esempio n. 3
0
        private void writeFileBytesOnTheRAM(TreeListNode node)
        {
            RowItem item = node.Content as RowItem;

            if (item.Extension == @"<Folder>")
            {
                return;
            }
            //
            // Check File Size to select Fat32 or Fat64 Reader (Larger than 2GB)
            // and Read all bytes of file or folder
            if (item.longSize / 1024 / 1024 / 1024 >= 2) // FAT64
            {
                item.Data = VirtualFAT64(item.Address);
            }
            else // FAT32
            {
                item.Data = VirtualFAT32(item.Address);
            }
        }