ThingWorx Edge C SDK > How to Set Up an Application > Initializing the File Manager (Optional)
Initializing the File Manager (Optional)
If using the directory browsing and file transfer capability of the SDK, perform the following steps:
1. Set the staging directory — You must set the staging directory before initializing the FileManager. Most likely, the default directory of the FileManager is owned by root. If owned by root, setting the staging directory requires one of the following:
Changing the location and ownership of the staging directory.
Running the application as a user with the correct permissions.
For example:

/* Staging Directory Variable */
/* must be set before initializing file manager*/
2. Initialize the FileManager singleton. For example:
/* Initialize the FileTransfer Manager */

3. Define any virtual directories — Virtual directories allow you to expose only a subset of the entire file system of the device to the platform for browsing and file transfer. This restriction is for both performance and security reasons. For example:

/* Create our virtual directories */
twFileManager_AddVirtualDir(thingName, "tw", "/opt/thingworx");
twFileManager_AddVirtualDir(thingName, "tw2", "/twFile_tmp");
Registering a virtual directory with the FileManager consists of mapping a unique name to an absolute path of a directory in your file system. Note that all subdirectories of the specified directory in the file system will be exposed to the platform. Multiple virtual directories can be defined and they need not be contiguous.
4. Register the FileCallback function that was previously defined so that the FileManager will call that function when any file transfer events occur. You can provide a wildcard filter so that only file transfer events of files that match the filter call the callback function. In addition, callbacks can be set up as “one-shots” such that the callback is unregistered automatically after it is invoked the first time. For example:

/* Register the file transfer callback function */
twFileManager_RegisterFileCallback(fileCallbackFunc, NULL, FALSE, NULL);
5. OPTIONAL: By default, WebSocket compression is used for all WebSocket communications, including file transfers. If you need to disable compression, call the tw_Api_DisableWebSocketCompression() function. Note that this function does not return anything.
In general, compression can be disabled after the API is initialized by calling the function:
twApi_DisableWebSocketCompression ();
When you disable compression, compression is not used for any WebSocket communications, including file transfers.
The C SDK v.2.1.2 provides improved logging for staging directory failures. If a file transfer fails to complete when the staging directory is on a separate partition (RAMDisk) from the final destination, use a DEBUG build of the application to view the logging around this failure (in twListEntities()).