示例#1
0
        // Cleans up and links contents of the source directory to target directory.
        private static void prepareSymbolicLinks(DirectoryInfo source, DirectoryInfo target)
        {
            var fm = new NSFileManager();

            fm.ChangeCurrentDirectory(target.FullName);

            NSError ns_error = new NSError();

            foreach (DirectoryInfo dir in source.GetDirectories())
            {
                var tmp_path = Path.Combine(target.FullName, dir.Name);
                if (Directory.Exists(tmp_path))
                {
                    Directory.Delete(tmp_path, true);
                }
                if (File.Exists(tmp_path))
                {
                    File.Delete(tmp_path);
                }
                fm.CreateSymbolicLink(dir.Name, dir.FullName, out ns_error);
            }

            foreach (FileInfo file in source.GetFiles())
            {
                var tmp_path = Path.Combine(target.FullName, file.Name);
                if (Directory.Exists(tmp_path))
                {
                    Directory.Delete(tmp_path, true);
                }
                if (File.Exists(tmp_path))
                {
                    File.Delete(tmp_path);
                }
                fm.CreateSymbolicLink(file.Name, file.FullName, out ns_error);
            }
        }