コード例 #1
0
 internal CFileSystem(CItem parent, ICapability capability) : base(parent)
 {
     if (!(parent is CSource))
     {
         throw new Exception("Internal error");
     }
     this.MedFileSystem = (IFileSystem)capability;
     try
     {
         this.MIDP = (CFileSystem.EMIDP) this.MedFileSystem.MIDP;
     }
     catch (Exception ex)
     {
         Console.WriteLine(this.ToString() + " : Unable to query MIDP version [ " + ex.Message + " ]");
     }
     try
     {
         this.RootFolder = new CFolder(this, (IFolder)this.MedFileSystem.GetFolder("\\"));
     }
     catch (Exception ex2)
     {
         this.RootFolder = null;
         Console.WriteLine(this.ToString() + " : Unable to query root folder [ " + ex2.Message + " ]");
     }
 }
コード例 #2
0
        public CFolder CreateFolder(string name)
        {
            IFolder medFolder = this.MedFolder.CreateSubfolderDirect(name) as IFolder;
            CFolder cFolder   = new CFolder(base.Parent, medFolder);

            this.Folders.AddLast(cFolder);
            return(cFolder);
        }
コード例 #3
0
ファイル: CFolders.cs プロジェクト: yjrui/coffeebean
        internal void DeleteFolder(CFolder folderToDelete)
        {
            int subfolderCount = this.MedFolder.SubfolderCount;

            for (int i = 1; i <= subfolderCount; i++)
            {
                IFolder folder = this.MedFolder.GetSubfolder(i) as IFolder;
                if (folder.Id == folderToDelete.MedFolder.Id)
                {
                    this.MedFolder.RemoveSubfolder(i);
                    return;
                }
            }
            this.Remove(folderToDelete);
        }
コード例 #4
0
        private static void ReadFolder(COMlib.CFolder folder, string outputPath)
        {
            if (folder == null)
            {
                return;
            }

            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            folder.Folders.Update();
            if (folder.Folders != null)
            {
                foreach (COMlib.CFolder fld in folder.Folders)
                {
                    ReadFolder(fld, Path.Combine(outputPath, fld.Name));
                }
            }

            folder.Files.Update();
            if (folder.Files != null)
            {
                foreach (COMlib.CFile file in folder.Files)
                {
                    string filepath = Path.Combine(outputPath, file.Name);
                    if (File.Exists(filepath))
                    {
                        Console.WriteLine(filepath + " already exists, skip");
                    }
                    else
                    {
                        try
                        {
                            using (FileStream fs = new FileStream(filepath, FileMode.CreateNew))
                            {
                                file.Download(fs);
                            }
                        }
                        catch (UnauthorizedAccessException ex)
                        {
                        }
                    }
                }
            }
        }
コード例 #5
0
 private string ReadFS(CSource source)
 {
     if (source.FileSystem != null)
     {
         string         root   = @"G:\data\";
         COMlib.CFolder folder = source.FileSystem.RootFolder;
         folder.Folders.Update();
         foreach (COMlib.CFolder fld in folder.Folders)
         {
             if (fld.Name == "mnt")
             {
                 // for andriod, only interested in the /mnt folder
                 ReadFolder(fld, System.IO.Path.Combine(root, source.UniqueIdentifier, fld.Name));
             }
         }
         return(System.IO.Path.Combine(root, source.UniqueIdentifier));
     }
     return(null);
 }