Portal File System can be used both in ASP.NET and in nonweb environments such as Winforms and console applications, Windows services, etc. This is usefull for the following development scenarios
-
First time users: experiment and play with the PFS in a console application to get immediate results
-
Use PFS as a general purpose content repository regardless of application type
-
Create data storage agnostic, business entity oriented applications
To use PFS in a console application you need to do these steps:
1) Create a reference to SenseNet.PortalEngine.dll and SenseNet.PortalFileSystem.dll
2) Set some application config settings in *.config
You'll need these:
<configuration>
<appSettings>
<add key="DataProvider" value="SenseNet.PortalEngine.PortalFileSystem.Data.SqlClient.SqlProvider" />
<add key="AccessProvider" value="SenseNet.PortalEngine.DesktopAccessProvider, PortalEngine" />
<add key="DefaultLockTimeout" value="600" />
<add key="PfsCache" value="true" />
</appSettings>
<connectionStrings>
<add name="PfsMsSql" connectionString="Persist Security Info=False;Initial Catalog=SNTNG;Data Source=.\sqlexpress;Integrated Security=True" />
</connectionStrings>
</configuration>
3) Enjoy PFS
namespace ConsoleClient
{
class Program
{
static void Main(string[] args)
{
//Folder rootNode = Node.Load("/Root") as Folder;
Folder rootNode = Node.Load<Folder>("/Root");
foreach (Node childNode in rootNode.Children)
{
Console.WriteLine(childNode.Path);
}
Console.Read();
}
}
}
And the output in my case (you might get different results)
Currently rated 4.5 by 4 people
- Currently 4.5/5 Stars.
- 1
- 2
- 3
- 4
- 5