locked
Programmatically read target of junction point RRS feed

  • Question

  • I am trying to read the target of a junction point, or symbolic link.

    Determining if a file is a reparsepoint is simple enough, but I'm having trouble finding the target.

    Any help is appreciated.  Here's what I have so far.  Thanks!

    #include "stdafx.h" 
     
    using namespace System; 
    using namespace System::IO; 
     
    ref class Scan { 
    public: 
        static int MaxPath=260000000; 
     
        static void ScanMyDir( String^ SourceDir,int RecursiveLevel) 
    	{
    
            if(RecursiveLevel<=MaxPath) 
    		{ 
                array <String^> ^fileEntries = Directory::GetFiles(SourceDir); 
                for each (String^ fileName in fileEntries)
    
    			{ 
                    //Console::WriteLine(fileName); 
                } 
            } 
            array<String^> ^SubDirEntries = Directory::GetDirectories(SourceDir); 
            for each (String^ subdir in SubDirEntries) 
                if ((File::GetAttributes(subdir) & FileAttributes::ReparsePoint) == FileAttributes::ReparsePoint) 
    				File::
    			{
    				Console::WriteLine(subdir);
    				//ScanMyDir(subdir,RecursiveLevel+1); 
    			
    			}
        } 
    }; 
     
    int main(array<System::String ^> ^args) { 
        Scan::ScanMyDir("c://",1); 
        Console::Read(); 
        return 0; 
    } 

    Tuesday, July 10, 2012 1:59 AM

Answers

All replies