예제 #1
0
        public static Path XmlPoke(this Path path, string xpath, string value)
        {
            if (path == null)
                return path;

            foreach (var file in path.AllFiles())
            {
                try
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(file.FullPath);

                    foreach(XmlNode n in doc.SelectNodes(xpath)){
                        n.Value = value;
                    }

                    doc.Save(file.FullPath);

                }catch(Exception ex){}
            }

            return path;
        }
예제 #2
0
 /// <summary>
 /// Zips all files in the path to the target.
 /// </summary>
 /// <param name="path">The files to compress.</param>
 /// <param name="target">
 /// The path of the target zip file.
 /// If target has more than one file, only the first one is used.</param>
 /// <param name="fileSystemToZip">
 /// A function that maps the paths of the files and directories to zip into relative paths inside the zip.
 /// </param>
 /// <returns>The zipped path.</returns>
 public static Path Zip(this Path path, Path target, Func<Path, Path> fileSystemToZip)
 {
     var files = path.AllFiles()
        .ToDictionary(
            fileSystemToZip,
            p => p);
     Zip(target, new Path(files.Keys), p => files[p].ReadBytes());
     return target;
 }
예제 #3
0
 /// <summary>
 /// Zips all files in the path to the target.
 ///     <remarks>
 ///     When a directory is being pointed to as a source, all contents are recursively added.
 ///     Individual files are added at the root, and directories are added at the root under their name.
 ///     To have more control over the path of the files in the zip, use the overload.
 ///     </remarks>
 /// </summary>
 /// <param name="path">The files to compress.</param>
 /// <param name="target">
 /// The path of the target zip file.
 /// If target has more than one file, only the first one is used.
 /// </param>
 /// <returns>The zipped path.</returns>
 public static Path Zip(this Path path, Path target)
 {
     var files = path.AllFiles()
         .ToDictionary(
             p => p.MakeRelativeTo(path),
             p => p);
     Zip(target, new Path(files.Keys), p => files[p].ReadBytes());
     return target;
 }