Component for embedding multiple files into a single storage file, preserving their original format. A storage file is an object that has a familiar tree structure similar to a file system in which files and variables of various types can be placed. No archiving. Work with embed files could be done directly without unpacking them. No need to save and load dozens of separate files. With PBFileStorage you can create your own professional file format, similar to Excel, Word, PowerPoint, which is easy to work with.
Prerequirements
OS compatibility
7 SP2 x64 |
8 x64 |
8.1 x64 |
10 x64 |
11 x64 |
RAD Studio compatibility
10 Seattle |
10.1 Berlin |
10.2 Tokyo |
10.3 Rio |
10.4 Sydney |
11 Alexandria |
1 user
3 users
5 users
10 users
Site license
Free components in a bundle
Buy a bundle now and enjoy all new component releases for free during the update period. |
Keep track of multiple versions
You will get access to all older versions and a detailed changelog. |
Free new features
Get all new component features for free during the free update period. |
Install once use forever
Our products are not time limited. |
Source code promise
In case our component will become obsolete and we no longer support it, we will provide you its source code. So you don’t have to worry about a replacement. |
References:
> QSG code example provided with the installer
After installation, a group PyBridge will appear in the Tool Palette of Delphi, where you can find the new component TPBFileStorage
New component TPBFileStorage can be found in the Tool Palette under PyBridge group
Place TPBFileStorage on the form and set up its main properties:
- FileName – full path to the storage file
- Name – name of the storage file
Now PBFileStorage is ready to be used. A file storage file is an object that has a familiar tree structure similar to a file system in which files and variables of various types can be placed. To demonstrate how it works, let’s create a very simple application with main component functions. Add buttons as displayed below. Add one Memo field for displaying status messages about the execution of the called functions. Add another Memo field for displaying the tree structure of the storage file.
Application layout to demonstrate basic PBFileStorage functions
First, it is necessary to initialize the work with FileStorage with the OPEN command. In this case, we either create a new file or open an existing file:
1 2 3 4 |
procedure TFileStorageDemo.OpenButtonClick(Sender: TObject); begin PBFileStorage1.OpenStorage; end; |
To display the result of initializing the storage file, create an OnOpen event handler:
1 2 3 4 5 6 7 8 9 |
procedure TFileStorageDemo.PBFileStorage1Open(const AFileName: string); begin Memo1.Lines.Add('File ' + AFileName + ' is Opened'); if PBFileStorage1.FileIsStorage then Memo1.Lines.Add('File Is a Storage') else Memo1.Lines.Add('File Is not a Storage'); DrawTree; end; |
Events list of PBFileStorage object
Press “Open” to open a storage file and display it’s tree structure
In the “Create dir” button click event handler, create two directories:
1 2 3 4 5 6 7 8 9 10 11 12 |
procedure TFileStorageDemo.Create_dirButtonClick(Sender: TObject); begin if PBFileStorage1.CreateDirectory('a\b\c') then Memo1.Lines.Add('CreateDirectory - OK') else Memo1.Lines.Add('CreateDirectory - FALSE'); if PBFileStorage1.CreateDirectory('d\e') then Memo1.Lines.Add('CreateDirectory - OK') else Memo1.Lines.Add('CreateDirectory - FALSE'); end; |
To display the result of creating directories, create an OnCreateDirectory event handler:
1 2 3 4 5 |
procedure TFileStorageDemo.PBFileStorage1CreateDirectory(const APath: string); begin Memo1.Lines.Add('Directory ' + APath + ' is created'); DrawTree; end; |
Press “Create dir” to create two directories and update a tree structure
In the “Write” button click event handler, create a variable and save its value in the file space of our storage file in the form of the file “test” in the “d\e” directory created earlier:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
procedure TFileStorageDemo.WriteButtonClick(Sender: TObject); var st: integer; begin st := 125; if PBFileStorage1.Write('d\e\test', st) then begin Memo1.Lines.Add('Write - OK'); Memo1.Lines.Add(Inttostr(st)); end else Memo1.Lines.Add('Write - FALSE'); end; |
To display the result of writing a value to a variable, create an OnWrite event handler.
1 2 3 4 5 |
procedure TFileStorageDemo.PBFileStorage1Write(const APath, ADataType: string); begin Memo1.Lines.Add('Write ' + APath + ' (' + ADataType + ')'); DrawTree; end; |
Press “Write” to write a “test” file and update a tree structure
In “Read” button click event handler, we will try to read the value of the previously created variable from the file “test” from the directory “a\b\c” (the file “test” is in the directory “d\e”):
1 2 3 4 5 6 7 8 9 10 11 12 |
procedure TFileStorageDemo.ReadButtonClick(Sender: TObject); var st: integer; begin if PBFileStorage1.Read('a\b\c\test', st) then begin Memo1.Lines.Add('Read - OK'); Memo1.Lines.Add(inttostr(st)); end else Memo1.Lines.Add('Read - FALSE'); end; |
To display the reading result, create an OnRead event handler:
1 2 3 4 |
procedure TFileStorageDemo.PBFileStorage1Read(const APath, ADataType: string); begin Memo1.Lines.Add('Read ' + APath + ' (' + ADataType + ')'); end; |
When you press the “Read” button, a message appears stating that it was not possible to read the value
Let’s use the “Move” function to move the file “test” from the directory “d\e” to the directory “a\b\c”:
1 2 3 4 |
procedure TFileStorageDemo.MoveButtonClick(Sender: TObject); begin PBFileStorage1.Move('d\e\test', 'a\b\c\'); end; |
To display the result of the move, create an OnMove event handler:
1 2 3 4 5 |
procedure TFileStorageDemo.PBFileStorage1Move(SrcPath, DstPath: string); begin Memo1.Lines.Add('Move ' + SrcPath + ' in ' + DstPath); DrawTree; end; |
Press “Move” to move “test” file to the “a\b\c” folder . Press “Read” to display the stored value “Hello World”
Let’s use the “Copy” function to copy the file “test” from the directory “a\b\c” to the directory “d\e”:
1 2 3 4 |
procedure TFileStorageDemo.CopyButtonClick(Sender: TObject); begin PBFileStorage1.Copy('a\b\c\test', 'd\e\'); end; |
To represent the move results, create an OnCopy event handler:
1 2 3 4 5 |
procedure TFileStorageDemo.PBFileStorage1Copy(SrcPath, DstPath: string); begin Memo1.Lines.Add('Copy ' + SrcPath + ' in ' + DstPath); DrawTree; end; |
Press “Copy” to copy “test” file to the folder «d\e\»
In the “Find” button click event handler, create a search procedure by the name of the file “test”:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
procedure TFileStorageDemo.FindButtonClick(Sender: TObject); var objlist: TStringArray; i, cnt: Integer; begin objlist := PBFileStorage1.Find('test'); cnt := Length(objlist); if cnt > 0 then begin for i := 0 to Pred(cnt) do begin Memo1.Lines.Add(objlist[i]); end; end; end; |
Press “Find” to find “TestString” file in the folders: «a\b\c» and «d\e\»
In the “Delete” button click event handler, create a procedure for deleting the subdirectory “b” from the directory “a” and the subdirectory “e” from the directory “d”:
1 2 3 4 5 6 7 8 9 10 11 12 |
procedure TFileStorageDemo.DeleteButtonClick(Sender: TObject); begin if PBFileStorage1.Delete('a\b') then Memo1.Lines.Add('Delete - OK') else Memo1.Lines.Add('Delete - FALSE'); if PBFileStorage1.Delete('d\e') then Memo1.Lines.Add('Delete - OK') else Memo1.Lines.Add('Delete - FALSE'); end; |
To display the result of deletion, create an OnDelete event handler:
1 2 3 4 5 |
procedure TFileStorageDemo.PBFileStorage1Delete(const APath: string); begin Memo1.Lines.Add(APath + ' is deleted'); DrawTree; end; |
Press “Delete” to delete subdirectories
In the “Save” button click event handler, create a procedure for saving the storage file:
1 2 3 4 |
procedure TFileStorageDemo.SaveButtonClick(Sender: TObject); begin PBFileStorage1.SaveStorage; end; |
To present the results of the save, create an OnSave event handler:
1 2 3 4 |
procedure TFileStorageDemo.PBFileStorage1Save(const AFileName: string); begin Memo1.Lines.Add(AFileName + ' is saved'); end; |
Press “Save” to save the storage file
When the “Close” command is executed, the current state of the storage file is saved and access to it is closed. To resume work with the file, you need to open it again.
1 2 3 4 |
procedure TFileStorageDemo.CloseButtonClick(Sender: TObject); begin PBFileStorage1.CloseStorage; end; |
Press “Close” to close the storage file
This example demonstrates how you can easily and quickly create and modify a tree-structured storage file with a help of PBFileStorage component. Now you can also enjoy the full power of PBFileStorage in your applications!