These are the methods that I-Load provides in order to store, read, and delete images using the FileSystem option:
![]() |
|
![]() |
In the ExampleSet A, the following examples indicate how to save, read, and delete images in the file system: A.201, A.202, A.203, and A204 |
"WebPublished" Option
I-Load is able to store images both in folders published on an internet site (web published) and in folders not accessible via HTTP.
The most classic example is the temporary file folder used by I-Load.
By default, I-Load uses the system temporary file folder (System.IO.Path.GetTempPath), or, in case of non Full Trust Asp.net 2.0 (o above) environments, the "App_Data" folder.
Both these folders are not normally accessible via HTTP protocol, however, I-Load is able to store images within them, and if necessary, to display the images in an internet browser.
Many of the methods provided by I-Load to load or store images in the file system have a parameter/option indicating whether the directory in question has been published on an internet site.
This way, I-Load is able to correctly calculate the URL needed to view an image.
When you load/store images within folders published on an internet site, it is recommended to always inform I-Load by using the specific parameters.
For example, when loading an image from a folder accessible via HTTP, you need to use this method:
| Load an image stored in a web published directory | Copy Code |
|---|---|
|
WebImage.LoadFromWebPublishedFileSystem(folderPath, imageId); | |
instead of this method:
| Load an image stored in a NON web published directory | Copy Code |
|---|---|
|
WebImage.LoadFromFileSystem(folderPath, imageId); | |
Or, to store an image in a folder accessible via HTTP, you need to use this method:
| Save an image into a web published directory | Copy Code |
|---|---|
|
ILoad1.Value.MoveToFileSystemFolderAndChangeId(true, folderPath, imageId); | |
instead of this method:
| Save an image into a NON web published directory | Copy Code |
|---|---|
|
ILoad1.Value.MoveToFileSystemFolderAndChangeId(folderPath, imageId); | |
![]() |
The files generated by I-Load using the "FileSystem" option are saved with the normal I-Load naming system. (see The I-Load file naming system). |
How to save an image uploaded with I-Load
Every time an image is uploaded or edited with I-Load, the component saves in the file system the generated new files as temporary files.
It’s the task of the application to permanently store these files in a database or in a directory of the file system.
If the application does not move the temporary files, they will be automatically deleted (normally at the end of the user’s session.)
See also I-Load temporary files.
To save an image within a directory of the file system, you can use the MoveToFileSystemFolder or MoveToFileSystemFolderAndChangeId methods of the WebImage class.
For example:
| Saving images into the file system | Copy Code |
|---|---|
|
if (ILoad1.Value != null) { // An image has been selected... // Setup the repository folder path string myRepositoryFolderPath = Server.MapPath("~/Repository/MyFolder"); // Setup the image id string myID = "123"; // Save the image into file system ILoad1.Value.MoveToFileSystemFolderAndChangeId(true, myRepositoryFolderPath, myID); } | |
The two methods are practically identical. The only difference is that the second method, (MoveToFileSystemFolderAndChangeId), allows you to change the image Id while moving it into a new folder.
This is a very common operation, because when I-Load stores the image in the temporary file folder, it uses an automatically generated ID, which generally must be changed.
Another way to store images with I-Load is the SynchronizeFileSystem method of the ILoad class.
This method allows you to automatically update the files in the file system using a single code line.
If necessary, I-Load will update the files in the file system, or, for example, delete them if the image has been removed.
This is the best method to manage the images uploaded with I-Load when using the FileSystem option.
If, for example, you are using the ID of a record as the ID for an I-Load uploaded image, this code line:
Copy Code | |
|---|---|
|
ILoad1.SynchronizeFileSystem(myRepositoryFolder, recordId.ToString()); | |
executed after saving the record, will allow you to keep updated the image associated with that record (within the myRepositoryFolder directory).
How to load an image saved with I-Load
You can use the LoadFromFileSystem or LoadFromWebPublishedFileSystem static methods of the WebImage class to load an image stored in the file system.
![]() |
The Load static method of the WebImage class is an alias of the LoadFromFileSystem function, maintained for compatibility reasons. |
These methods accept as parameters the folder path in which the images are saved and the ID of the image to be loaded.
To load an image within an I-Load instance, you can use this code:
Copy Code | |
|---|---|
|
ILoad1.Value = WebImage.LoadFromWebPublishedFileSystem(myRepositoryFolderPath, imageId); | |
If instead, you wish to visualize the image uploaded into a web page, you can use this code:
Copy Code | |
|---|---|
|
WebImage image = WebImage.LoadFromWebPublishedFileSystem(myRepositoryFolderPath, imageId); string imageUrlToDisplay = image.SelectedImage.FileUrl; | |
![]() |
If you are using one of the methods to load an image, and the image is not present in the file system, a System.IO.FileNotFoundException will be generated. This exception will be generated even if only the image XML index file is missing, given that such file is indispensable for loading an image. (See How many and which files are saved by I-Load). Before executing the LoadFromFileSystem or LoadFromWebPublishedFileSystem methods of the WebImage class, we recommend to always verify that the image is present in the file system, by using the specific ExistsInFileSystem method of the WebImage class. |
How to verify whether an image is present in the file system
You can verify whether an image is present in the file system using the ExistsInFileSystem method of the WebImage class.
Example:
Copy Code | |
|---|---|
|
if (WebImage.ExistsInFileSystem(myRepositoryFolderPath, imageId)) { ILoad1.Value = WebImage.LoadFromWebPublishedFileSystem(myRepositoryFolderPath, imageId); } | |
How to delete an image uploaded with I-Load
You can delete an image (and all its relative files) from the file system using the Delete instance method of the WebImage class, or the DeleteFromFileSystem static method of the same class.
Example:
Copy Code | |
|---|---|
|
WebImage.DeleteFromFileSystem(myRepositoryFolderPath, imageId); | |


