Sense/Net 6.0 Devblog
The development blog of Sense/Net 6.0
Back to Sense/Net

Using the Sense/Net Portal File System in non web environments

September 11, 2008 12:39 by Peter Zentai

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

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Bookmark and Share