我想这很简单,但我在DotNetZip示例或文档中找不到任何帮助.我需要将文件夹添加到包含文件夹和文件的zip文件中,我需要维护文件夹而不是仅压缩文件,但使用以下文件总是剥离文件夹:
using (ZipFile zip = new ZipFile())
{
string[] files = Directory.GetFiles(@TempLoc);
string[] folders = Directory.GetDirectories(@TempLoc);
zip.AddFiles(files, "Traces");
foreach (string fol in folders)
{
zip.AddDirectory(fol, "Traces");
}
zip.Comment = "These traces were gathered " + System.DateTime.Now.ToString("G");
zip.Save(arcTraceLoc + userName.Text + "-Logs.zip");
}
Run Code Online (Sandbox Code Playgroud)
我正在使用循环,因为我找不到类似于DotNetZip中的'AddFiles'的文件夹的功能.
谢谢.
我精通 OO C# 的基本用法,但我有点困惑,我不确定以下(来自大型项目的简化)究竟做了什么以及如何传递参数:
Class test1
{
private prefr iniread;
private void checkData()
{
this.iniread["string1"]["string2"][0][0]
}
}
public class prefr :
Component,
ISupportInitialize,
ISettingsLoader
{
#region Events
public event EventHandler Loading;
public event EventHandler Loaded;
public event EventHandler Saving;
public event EventHandler Saved;
#endregion
#region Attributes
private string _FileName;
private Dictionary<string, ppPrefSection> _Sections;
private Control _SaveControl;
private Control _FinishControl;
#endregion
#region Constructors
public prefr()
{
_Sections = new Dictionary<string, prefrSection>();
}
public prefr(IContainer container)
: this()
{
container.Add(this);
}
public …Run Code Online (Sandbox Code Playgroud) 我正在尝试初始化一个对象进行序列化,类对象是使用xsd.exe创建的.可以毫无问题地初始化各个属性,但在尝试初始化"无界"XSD属性时,我无法使用foreach循环遍历数组中的每个值并将其添加到对象:
object[] test = new object[0];
test[0] = "ring";
export export = new export();
export.info = new exportInfo
{
dateandtimeofexport = DateTime.Now,
duration = "10",
planningsoftware = new exportInfoPlanningsoftware
{
name = "",
major = "",
minor = "",
revision = "",
build = ""
},
exporter = new exportInfoExporter
{
version = new exportInfoExporterVersion
{
name = "",
major = "",
minor = "",
revision = "",
build = ""
},
module = new exportInfoExporterModule[]
{
foreach(Object x in …Run Code Online (Sandbox Code Playgroud) 我目前正在使用c#6,但是需要回到VS2013进行项目,所以想知道以下表达式身体功能成员是否具有与之前版本的C#中相同的"糖":
public string FullAddress => $"{Title} {FirstName} {LastName}, {Street}, {City} {ZIP}";
Run Code Online (Sandbox Code Playgroud)
Title,FirstName,Lastname等是在调用FullAddress之前在类中初始化的所有其他属性.