CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    May 2012
    Posts
    36

    Having trouble working with a Windows\System32 Folder

    Hello,

    I have been working for two days trying to figure out what is my problem with copying files from the local C:\windows\system32\certsrv\certenroll folder to a UNC path.

    My code working perfect if I use c:\source and c:\destination folders. But once I switch it to system32 I get this message from JIT

    System.IO.DirectoryNotFoundException was unhandled
    Message=Could not find a part of the path 'C:\Windows\System32\Certsrv\Certenroll'.

    I disabled UAC on another server and still same issue.

    So, one thing that I figure out is that a simple BrowseDialog box does not see all folders within system32 folder.

    Code:
    string sourcePath1 = @"C:\Windows\System32\CertSrv\CertEnroll";
    
    
    string targetPath1 = @"\\testserver\certs\certenroll";
    
                //Source Path 1 Operations
                foreach (var sourceFilePath in Directory.GetFiles(sourcePath1))
                {
                    string fileName = Path.GetFileName(sourceFilePath);
                    string destinationFilePath = Path.Combine(targetPath1, fileName);
    
                    System.IO.File.Copy(sourceFilePath, destinationFilePath, true);
    
                    //If we need to overwrite files, write an if else statement
                    //System.IO.File.Copy(sourceFilePath, destinationFilePath);
                }
    Has anyone come across this issue before.

    I also attached a screenshot of it for your review.

    Thanks for any help.

    Mike
    Attached Images Attached Images  

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Having trouble working with a Windows\System32 Folder

    Does the folder exist?

    Do you have permissions to access it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured