Exemple #1
0
 private static ReturnStuffer directoryCopyAsUser(string srcDir, string dstDir, bool recursive = true, bool overwrite = false)
 {
     return(ImpersonationHelper.ImpersonateWithReturnStuffer(ConfigHandler.Domain, ConfigHandler.Username, ConfigHandler.Password, () => directoryCopy(srcDir, dstDir, recursive, overwrite)));
 }
Exemple #2
0
        //private static ReturnStuffer directoryCopy_old(string srcDir, string dstDir, bool recursive = true, bool overwrite = false)
        //{
        //    ReturnStuffer result = new ReturnStuffer()
        //    {
        //        Result = false,
        //    };
        //    DirectoryInfo dir = new DirectoryInfo(srcDir);

        //    if (!dir.Exists)
        //    {
        //        throw new DirectoryNotFoundException("Source directory not found: " + srcDir);
        //    }

        //    DirectoryInfo[] dirs = dir.GetDirectories();

        //    // Create dst directories
        //    if (!Directory.Exists(dstDir))
        //    {
        //        Directory.CreateDirectory(dstDir);
        //    }

        //    if (!Directory.Exists(dir.Name))
        //    {
        //        Directory.CreateDirectory(Path.Combine(dstDir, dir.Name));
        //    }

        //    result.Files.Add(new FileSelection()
        //    {
        //        Path = Path.Combine(dstDir, dir.Name),
        //        State = FileState.TRANSFERRED,
        //        Type = FileSelectionType.DIRECTORY,
        //    });


        //    FileInfo[] files = dir.GetFiles();
        //    foreach (FileInfo file in files)
        //    {
        //        string temppath = Path.Combine(dstDir, dir.Name,file.Name);
        //        file.CopyTo(temppath, false);
        //        result.Files.Add(new FileSelection() {Path=temppath, State=FileState.TRANSFERRED, Type=FileSelectionType.FILE});
        //    }

        //    if (recursive)
        //    {
        //        foreach (DirectoryInfo subdir in dirs)
        //        {
        //            string temppath = Path.Combine(dstDir, dir.Name, subdir.Name);
        //            ReturnStuffer subresult = directoryCopy(subdir.FullName, temppath, recursive, overwrite);
        //            result.Files.AddRange(subresult.Files);
        //        }
        //    }
        //    result.Result = true;
        //    return result;
        //}


        private static ReturnStuffer fileCopyAsUser(string srcFilename, string dstDirname, bool overwrite) =>
        ImpersonationHelper.ImpersonateWithReturnStuffer(ConfigHandler.Domain, ConfigHandler.Username, ConfigHandler.Password, () => fileCopy(srcFilename, dstDirname, overwrite));
Exemple #3
0
 private static ReturnStuffer createDirectoryAsUser(string path)
 {
     return(ImpersonationHelper.ImpersonateWithReturnStuffer(ConfigHandler.Domain, ConfigHandler.Username, ConfigHandler.Password, () => createDirectory(path)));
 }