|
Manipulating Files and
Directories In addition to uploading and downloading files, you can use ActiveFile for general purpose file and directory manipulation using a variety of methods provided by the File and Directory object. Manipulation Topics
|
|
Manipulating files When you upload files, a FormInput object is added to the Post.FormInputs collection for each file. Referencing these files is as simple as referencing the File property of the FormInput object. The following script demonstrates how to display information about an uploaded file:
However, you may need to access files on the server that were not just uploaded. In these cases, you can create a File object and initialize it to point to the specific file you are interested. The following script demonstrates how to access an arbitrary file using only a File object:
By initializing the File.Name property to a path, you can access any arbitrary file as long as you have the necessary permissions. See Security Considerations for more details. Once you have a File object that is referencing a file, you can manipulate it in a variety of ways including renaming, copying, and deleting. For more details and examples see the File object reference. |
|
Using ActiveFile, you can access any local or network drive that accessible from your server as long as you have the necessary permissions. The root directory of all drives that are associated with drive letters can be access using the Computer.Drives collection as in the following example:
In some cases you may need to access a specific directory to locate files or other information. The following script demonstrates how to access an arbitrary directory using a Directory object:
By initializing the Directory.Path property to a path, you can access any arbitrary directory as long as you have the necessary permissions. See Security Considerations for more details. Once you have a Directory object that is referencing a directory, you can manipulate it in a variety of ways including renaming and deleting. For more details and examples see the Directory object reference. |
|
Securing files
and directories Both the File and Directory object have an ACEs collection. The ACEs collection represents the list of users and groups that can access the file or directory and what priviledges they have been granted. By default, the IIS anonymous account does not have permission to access security information. In the example below, the Computer.Impersonate method is used to login under a different NT account that has the necessary permissions.
Note that it is possible to use an account other than the administrator account to access security information. Even the IIS anonymous account can be configured to be used for this purpose. See Security Considerations for more information. In addition to accessing security information, is it also possible to add and update information in the ACEs collection. The following example demonstrates how to give a particular user read access to a file.
|