NET Link Tracker
CreateNonExpiringDownload Method
Example 



KellermanSoftware.NetLinkTracker Namespace > LinkLogic Class : CreateNonExpiringDownload Method
The path to the file
Create a tracked link to a download that never expires
Syntax
'Declaration
 
Public Function CreateNonExpiringDownload( _
   ByVal filePath As String _
) As TrackedLink
'Usage
 
Dim instance As LinkLogic
Dim filePath As String
Dim value As TrackedLink
 
value = instance.CreateNonExpiringDownload(filePath)
public TrackedLink CreateNonExpiringDownload( 
   string filePath
)
public:
TrackedLink^ CreateNonExpiringDownload( 
   String^ filePath
) 

Parameters

filePath
The path to the file

Return Value

The created tracked link
Example
LinkLogic linkLogic = new LinkLogic(); //Trial Mode
LinkLogic linkLogicLicensed = new LinkLogic("place user name here", "place license key here");  //License Mode
 
//Use a in memory mock database for testing
ILinkTrackerDatabaseLogic databaseLogic = new LinkTrackerMockDatabase();
 
linkLogic.DatabaseLogic = databaseLogic;
 
//Create a dummy file for testing
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.txt");
File.WriteAllText(filePath, "This is a test");
 
TrackedLink createdLink = linkLogic.CreateNonExpiringDownload(filePath);
 
TrackedLink link = linkLogic.GetLinkByGuid(createdLink.LinkGuid);
LinkStatus status = linkLogic.CheckLinkStatus(link);
 
//The status will be Active
Console.WriteLine("Status: " + status);
 
//Get a friendly status for the user
Console.WriteLine("Friendly Status: " + linkLogic.GetFriendlyStatus(link));
 
//Get the associated File Path
Console.WriteLine("File Path:  " + createdLink.FilePathOrUrl);
 
//This will stream the file to the browser
if (HttpContext.Current != null) //This check not needed if running in ASP.NET process
    linkLogic.ProcessLink(createdLink);
Dim linkLogic As New LinkLogic() 'Trial Mode
Dim linkLogicLicensed As New LinkLogic("place user name here", "place license key here") 'License Mode
 
'Use a in memory mock database for testing
Dim databaseLogic As ILinkTrackerDatabaseLogic = New LinkTrackerMockDatabase()
 
linkLogic.DatabaseLogic = databaseLogic
 
'Create a dummy file for testing
Dim filePath As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.txt")
File.WriteAllText(filePath, "This is a test")
 
Dim createdLink As TrackedLink = linkLogic.CreateNonExpiringDownload(filePath)
 
Dim link As TrackedLink = linkLogic.GetLinkByGuid(createdLink.LinkGuid)
Dim status As LinkStatus = linkLogic.CheckLinkStatus(link)
 
'The status will be Active
Console.WriteLine("Status: " & status)
 
'Get a friendly status for the user
Console.WriteLine("Friendly Status: " & linkLogic.GetFriendlyStatus(link))
 
'Get the associated File Path
Console.WriteLine("File Path:  " & createdLink.FilePathOrUrl)
 
'This will stream the file to the browser
If HttpContext.Current IsNot Nothing Then 'This check not needed if running in ASP.NET process
    linkLogic.ProcessLink(createdLink)
End If
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

LinkLogic Class
LinkLogic Members