Outlook error when adding .pst

File access is denied. You do not have the permission required to access the file .pst

Had the above error when trying to add a PST data file to Outlook. Brand new machine, joined to the domain. I had copied the file across the network to the new machine. I tried moving the file into different locations, I tried taking ownership of the file, I tried setting the domain user as a local administrator, check that the ‘Read Only’ flag was not set, I tried moving, instead of copying the file (this has bitten me in the past, believe it or not) etc. After some searching, Google came up with the answer:

icacls file /setintegritylevel L

I found this here:

http://www.office-outlook.com/outlook-forum/index.php/m/400393/

I ran the icacls command from a command window, however I needed to open that command windows as an administrator, otherwise I got a similar ‘Access Denied’ message. One thing I did not check, which probably should be the first thing to check, was running Outlook as an administrator. However, as I usually add PST’s from the Mail option in control panel, this did not immediately occur to me.

 

 

LINQ: ‘Week Commencing’ TreeNodes

I needed a way to create a TreeView in VB.NET that contained a node for each month of the year, and each month node had to contain a node for each Monday within that month. A ‘Week Commencing’ type of view. This type of problem always seems better solved with LINQ, so here’s how I did it:

Private Function GenNode() As TreeNode

        Dim rootNode As New TreeNode("Week Commencing")

' Create a list containing every date of the year
        Dim dateList As New List(Of Date)
        Dim dateIterator As New Date(Year(Now), 1, 1)
        Do Until dateIterator.Year <> Year(Now)
            dateList.Add(dateIterator)
            dateIterator = dateIterator.AddDays(1)
        Loop

' Now, using LINQ, create the TreeNodes
        Dim t = From d In dateList Group d By m = d.Month Into Group Select
            New TreeNode(MonthName(m),
                (From d1 In dateList Where d1.Month = m And d1.DayOfWeek = DayOfWeek.Monday Select New TreeNode(d1.ToString("dd-MM-yyyy"))).ToArray) Distinct

        rootNode.Nodes.AddRange(t.ToArray)

        Return rootNode

    End Function

For more information on LINQ, see the following link 🙂

http://msdn.microsoft.com/en-us/library/vstudio/bb397926.aspx

The roguelj project dumping ground. Music, Electronics, Coding, SQL, & more…