Click or drag to resize

DocumentViewerDocumentLocation Property

Gets or sets the file system location for the file specified in Document property. By default, the file is considered on disk but you can use this property to load files from any of the supported file systems like UNC paths with password, Amazon S3 and Azure Blob. When specified Document property should be set to a relative path for this location. (e.g. "Document.docx" or "SomeFolder\Document.docx")

Namespace:  GleamTech.DocumentUltimate.AspNet.UI
Assembly:  GleamTech.DocumentUltimate (in GleamTech.DocumentUltimate.dll) Version: 5.4.2
Syntax
public Location DocumentLocation { get; set; }

Property Value

Type: Location
Examples

Using physical/virtual path for document location:

//Setting physical location via string:
//(can also be virtual path string like "~/App_Data/SomeFolder")
documentViewer.DocumentLocation = @"c:\SomeFolder";
//Same as above
documentViewer.DocumentLocation = @"Type=Physical; Path=c:\SomeFolder";
//Setting physical location via a PhysicalLocation instance (same as above)
documentViewer.DocumentLocation = new PhysicalLocation
{
    Path = @"c:\SomeFolder"
};

//Now set Document property as a relative path for this location.
//In this example "c:\SomeFolder\Document.docx" will be loaded
documentViewer.Document = "Document.docx";

//---------------------------------------

//Using a UNC share for document location
//User Name can be speficied as Domain\User, User@Domain (UPN format), MachineName\User
//or User (local user). If a value contains semi-colon character, that value should be enclosed
//in single quotes (eg. Password='PASSWORD') or double quotes (eg. Password="PASSWORD").
documentViewer.DocumentLocation = @"Path=\\server\share; User Name=USERNAME; Password=PASSWORD";
//Same as above
documentViewer.DocumentLocation = new PhysicalLocation
{
    Path = @"\\server\share",
    UserName = "USERNAME",
    Password = "PASSWORD"
};

//If Windows Authentication is used in IIS for this site, location can be specified like this
//to connect as the already authenticated user: 
documentViewer.DocumentLocation = @"Path=\\server\share; Authenticated User=Windows";
//Same as above
documentViewer.DocumentLocation = new PhysicalLocation
{
    Path = @"\\server\share",
    AuthenticatedUser = AuthenticatedUser.Windows
};

//Now set Document property as a relative path for this location.
//In this example "\\server\share\SomeFolder\Document.docx" will be loaded
documentViewer.Document = @"SomeFolder\Document.docx";

Using Amazon S3 for document location:

//Setting Amazon S3 location via string:
documentViewer.DocumentLocation = "Type=AmazonS3; Bucket Name=BUCKET; Region=eu-central-1; Access Key Id=XXX; Secret Access Key=XXX";
//Setting Amazon S3 location via an AmazonS3Location instance (same as above)
documentViewer.DocumentLocation = new AmazonS3Location
{
    BucketName = "BUCKET",
    Region = "eu-central-1",
    AccessKeyId = "XXX",
    SecretAccessKey = "XXX",
    //You can also a specific path relative to the root
    //Path = "Some/Folder"
};

//Now set Document property as a relative path for this location.
//In this example "[BUCKET]/SomeFolder/Document.docx" will be loaded
documentViewer.Document = @"SomeFolder\Document.docx";

Using Azure for document location:

//Setting Azure Blob location via string:
documentViewer.DocumentLocation = "Type=AzureBlob; Container=CONTAINER; Account Name=XXX; Account Key=XXX";
//Setting Azure Blob location via an AzureBlobLocation instance (same as above)
documentViewer.DocumentLocation = new AzureBlobLocation
{
    Container = "CONTAINER",
    AccountName = "XXX",
    AccountKey = "XXX",
    //You can also a specific path relative to the root
    //Path = "Some/Folder"
};

//Now set Document property as a relative path for this location.
//In this example "[CONTAINER]\SomeFolder\Document.docx" will be loaded
documentViewer.Document = @"SomeFolder\Document.docx";
See Also