10 Replies Latest reply on Aug 16, 2010 10:12 AM by chris.campbell

    Find size of StorageVolume?

    balasubramaniyan.S Level 1

      Hi

       

      I can find spaceAvailable of StorageVolume using "storageVolume.rootDirectory.spaceAvailable".
      Is it possible to find size of StorageVolume?

       

      Thanks

      Bala.S

        • 1. Re: Find size of StorageVolume?
          thilgen Level 4

          Bala.S

           

          This is not currently supported - but is a great idea.

           

          Could you please log a feature request at: http://ideas.adobe.com/air/

           

          Thanks,

           

          Chris Thilgen

          AIR Engineering

          • 2. Re: Find size of StorageVolume?
            balasubramaniyan.S Level 1

            Hi

             

            Posted idea in Adobe AIR Ideas.

            I can find file size using FileRefrence. But how can convert File object to FileRefrence object. Is FileRerfrence use only for upload/download? After browse only i can find size for selected file. Is it possible to assign file without browse to the Filerefrence object. How!!!???

             

             

            Thanks

            Bala.S

            • 3. Re: Find size of StorageVolume?
              thilgen Level 4

              File inherits from FileReference - so a File is a FileReference.

               

              Yes, FileReference is only used for upload/download. But File objects can be created/used at any time (in AIR).

               

              You can create a new File object in a variety of ways

               

              1) passing a local path to the constructor

               

                var f:File = new File("c:\\test.text");

               

              2) using relative paths (better cross-platform solution)

               

                var f:File = File.documentsDirectory.resolvePath("test.txt");

               

              Please refer to the AS3 reference for the File object for additional information:

               

              http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/filesystem/File.html#File()

               

              Hope this helps.

               

              Chris Thilgen

              AIR Engineering

              1 person found this helpful
              • 4. Re: Find size of StorageVolume?
                balasubramaniyan.S Level 1

                Thanks for your reply,

                I already know about passing local path and relative path.

                I want to get size of the file directory. How can i get it?

                I think not possible. Is it correct?

                 

                Thanks

                 

                Regards

                Bala.S

                • 5. Re: Find size of StorageVolume?
                  lisachao Adobe Employee

                  Would this work?

                   

                  import flash.filesystem.StorageVolumeInfo;
                  import flash.filesystem.StorageVolume;
                  import flash.filesystem.File;
                  import flash.events.StorageVolumeChangeEvent;

                   

                  public function mountEvtHandler(mountEvt:StorageVolumeChangeEvent):void {
                     var mountedVolume:StorageVolume = mountEvt.storageVolume;
                     var fileHandle:File = mountEvt.rootDirectory;
                     var spaceAvailableString:String = fileHandle.spaceAvailable.toString();
                  }

                  • 6. Re: Find size of StorageVolume?
                    balasubramaniyan.S Level 1

                    i know how to get space Available, but i need to find total size.

                    • 7. Re: Find size of StorageVolume?
                      lisachao Adobe Employee

                      What about this?

                       

                      import flash.filesystem.File;
                      import flash.system.Capabilities;
                        
                      private function getDrives():void
                      {
                            var os:String = Capabilities.os.substr(0, 3).toLowerCase();
                            var currentDrives:Array = (os=="mac") ? new File('/Volumes/').getDirectoryListing() : File.getRootDirectories() ;
                            for each(var file:File in currentDrives){
                                trace ("Drive: " + file.name + " Size: " + file.size);
                            }
                      }
                      1 person found this helpful
                      • 8. Re: Find size of StorageVolume?
                        tonysilvestri

                        Similar to the post before me:

                         

                         

                                public function determineIfSpaceIsAvailable(e:SpaceAvailableEvent) : void{

                                    var volumes : Vector.<StorageVolume> = StorageVolumeInfo.storageVolumeInfo.getStorageVolumes();

                                    for each (var volume:StorageVolume in volumes)

                                    {

                                        if(volume.isRemovable && volume.isWritable){

                                            checkSpace(volume);

                                            break;

                                        } else if(volumes.lastIndexOf(volumes)){

                                            var event:ThumbDriveNotFoundEvent = new ThumbDriveNotFoundEvent(ThumbDriveNotFoundEvent.THUMB_DRIVE_NOT_FOUND);

                                           dispatcher.dispatchEvent( event );

                                        }

                                    }

                                }

                         

                         

                                private function checkSpace(_currentVolume : StorageVolume):void{
                                    var vol : StorageVolume = _currentVolume;
                                    var spaceAvailable = vol.rootDirectory.size;
                                }

                         

                         

                         

                        in my case I needed to know the space available on a thumb drive.  This is how I did it....

                        • 9. Re: Find size of StorageVolume?
                          balasubramaniyan.S Level 1

                          Thanks

                           

                          It works. Is the size return in bytes?

                          • 10. Re: Find size of StorageVolume?
                            chris.campbell Adobe Employee

                            Moved discussion to the Adobe AIR Development forum