2

So my problem is that I want to export my user account. But inside C:\%user%\AppData\Local\ are System Hardlinks e.g.: Application Data which I obviously have no right to use them.

Is there a way to exclude those System Hardlinks from the copying process?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Amachi
  • 100
  • 11

2 Answers2

0

I'm not sure what you mean with hard links, but this might help you

foreach (var dir in new DirectoryInfo(@"c:\users\xxxxxx\AppData\Local").GetDirectories())
{
    if (dir.Attributes.HasFlag(FileAttributes.ReparsePoint))
    {
        Console.WriteLine(dir.Name + " is symbolic, skip it");
    }
    else
    {
        //do your copy here
    }
}
Nino
  • 6,931
  • 2
  • 27
  • 42
0

So I fixed the issue with Exception handling, doing it this way:

FileInfo[] sourceFiles = null;

            try {

                sourceFiles = new DirectoryInfo(sourcePath).GetFiles();
            } catch (Exception ex) {

                WriteLog(LogPath, ex + "");                                 
                return;
            }

Since I'm a bit new to exception handling, I couldn't work it out for the first few hours on this problem.

Amachi
  • 100
  • 11