--- myst: substitutions: ico_method: |- ```{image} /img/code_reference/net_library/method.ico :width: 15px ``` ico_prop: |- ```{image} /img/code_reference/net_library/prop.ico :width: 15px ``` --- # IFileService Interface Contains functionality to add, search and manipulate files and folders in your package. **Namespace:** bcpDevKit\ **Assembly:** bcpDevKit.dll ## Syntax ```csharp public interface IFileService ``` ## Methods | Type | Name | Description | |------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | {{ico_method}} RootObject | GetRootFolder() | Returns the Vault root folder. | | {{ico_method}} [FolderObject] | AddFolder(string folderName) | Creates the passed folder structure. *folderName* is a valid vault folder path. | | {{ico_method}} [FileObject] | AddFileWithIteration(string targetFileName, string sourceFileName, bool isLibrary=false) | Creates the passed folder structure and file. *targetFileName* is the path to the file destination, *sourceFileName* is the path to the sourceFile, if *isLibrary* is true, the file gets handled as content center file. | | {{ico_method}} [FileObject] | AddFileWithIterationRef(string targetFileName, long checksum, [DateTime] createDate, bool isLibrary=false) | Creates folder structure and a file with an IterationRef referencing a file that already exists in the Vault.
*targetFileName* is the path to the file destination, *checksum* is the checksum of the file in Vault, *createDate* is the creation date of the file in Vault **(requires milliseconds)**, if *isLibrary* is true, the file gets handled as content center file. | | {{ico_method}} IEnumerable\<[FileObject]> | SearchFilesByName([FolderObject] rootFolderOfSearch, string fileName, bool searchRecursive=true) | Looks for files by their name in a specific folder and its subdirectories. *rootFolderOfSearch* is the first folder where the search is performed, *fileName* is the name the function searches for. | | {{ico_method}} [FileObject] | SearchFileByLocation(string fileLocation) | This function searches for a specific file in the export package if *fileLocation* exists. | | {{ico_method}} [FolderObject] | SearchFolderByPath(string folderPath) | Searches the export package for a specific folder if *folderPath* exists. | [FileRevision]: /code_reference/net_library/entitiestable/filerevision [FileObject]: /code_reference/net_library/entitiestable/fileobject [FileIteration]: /code_reference/net_library/entitiestable/fileiteration [FolderObject]: /code_reference/net_library/entitiestable/folderobject [DateTime]: https://learn.microsoft.com/en-us/dotnet/api/System.DateTime?view=netframework-4.7 ## Remarks The functions `AddFileWithIteration` and `AddFileWithIterationRef` can handle situations where a file or folder already exists. If a library file is added to a folder that is not marked as „Library“, the folder will not be marked as a library. `SetLibrary(true)` can by used to mark the folder as a library. Only if the folder has to be created automatically or is already a library, the file will be added as a content center. ## Examples **Search Files by Name** ```csharp var searchRecursive = true; var foundFiles = bcpService.FileService.SearchFilesByName(GetMyFolder(), "Pad Lock.iam", searchRecursive); ```