What is the best way to check the reprocessing point in .net (C #)?

My function is pretty much a standard search function ... I have included it below.

In the function, I have 1 line of code responsible for trimming the Repart NTFS points.

if (attributes.ToString().IndexOf("ReparsePoint") == -1) 

The problem is that I get the error Access to the path 'c:\System Volume Information' is denied.

I debugged the code, and only runtime attributes for this directory:

  System.IO.FileAttributes.Hidden | System.IO.FileAttributes.System | System.IO.FileAttributes.Directory 

I am executing this code on a Windows 2008 server machine, any ideas what I can do to cure this error?

 public void DirSearch(string sDir) { foreach (string d in Directory.GetDirectories(sDir)) { DirectoryInfo dInfo = new DirectoryInfo(d); FileAttributes attributes = dInfo.Attributes; if (attributes.ToString().IndexOf("ReparsePoint") == -1) { foreach (string f in Directory.GetFiles(d, searchString)) { //lstFilesFound.Items.Add(f); ListViewItem lvi; ListViewItem.ListViewSubItem lvsi; lvi = new ListViewItem(); lvi.Text = f; lvi.ImageIndex = 1; lvi.Tag = "tag"; lvsi = new ListViewItem.ListViewSubItem(); lvsi.Text = "sub bugger"; lvi.SubItems.Add(lvsi); lvsi = new ListViewItem.ListViewSubItem(); lvsi.Text = d;//"C:\\Users\\Administrator\\Downloads\\MediaMonkey.GOLD.EDITION.v.3.0.2.1134.[Darkside].[Demonoid].[Grim.Reaper]"; lvi.SubItems.Add(lvsi); listView1.Items.Add(lvi); } DirSearch(d); } } } 
+3
source share
3 answers

No one has access to system volume information except for the SYSTEM account. Therefore, either change the directory permissions. Or it is much better to catch the exception and continue.

+3
source

I'm not sure the answer to the question is, but please change your attribute check to use the correct bitwise operations!

 if (attributes.ToString().IndexOf("ReparsePoint") == -1) 

... much more correctly written as ...

 if ((attributes & FileAttributes.ReparsePoint) == 0) 
+15
source

Perhaps this article may help you (they explain how to access this folder):

http://support.microsoft.com/kb/309531

A desperate decision is an attempt.

+1
source

All Articles