Search code examples
c#user-profilefile-copyinghardlink

Exclude System Hardlinks from File.Copy


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?


Solution

  • 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.