Using API to work with BizForm files

This article describes where BizForm files are stored and how we can work with them using API.
BizForm files are exclusively stored in the file system. You can find them by default in following location:

<your project>/<site name>/BizFormFiles/<GUID>.<extension>

Example: ~/CorporateSite/BizFormFiles/21a23606-d038-4551-b02a-34626065ec11.jpg

Of course, you can change the location of BizForm files in CMS Site Manager -> Settings -> Select your web site -> Files section in “BizForm files folder” setting.

From database point of view, following information should be stored in one of your BizForm table columns:


Example: 21a23606-d038-4551-b02a-34626065ec11.jpg/DocumentName.jpg

You can access the file using following URL:

~/CMSModules/BizForms/CMSPages/GetBizFormFile.aspx?filename=" + “<GUID>.<extension>” + "&sitename=" + SiteName



Direct saving to the disk can be done with usage of DataHelper class:

// Path to BizForm files in file system.
string filesFolderPath = FormHelper.GetBizFormFilesFolderPath(this.SiteName);

// Get file size and path
string filePath = filesFolderPath + fileName;

// Ensure disk path
DirectoryHelper.EnsureDiskPath(filePath, UrlHelper.WebApplicationPhysicalPath);

DataHelper.SaveFileToDisk(filePath, postedFile.InputStream);

On the other hand you may need to retrieve the file from the disk. Here is an example:

string fileNameString = "605b0932-660c-43cf-b2e0-b5ccf519f75f.png/originalFileName.png";

BasicForm bf = new BasicForm();

string fileName = bf.GetGuidFileName(fileNameString);
string filePath = FormHelper.GetBizFormFilesFolderPath(CMSContext.CurrentSiteName) + fileName;

if (File.Exists(filePath))
FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);

// Add attachment
Attachment attachment = new Attachment(stream, bf.GetFileNameForUploader(fileNameString));


See also: Creating new record using API

Applies to: 6.0 and later
Share this article on   LinkedIn