本文整理汇总了C#中Ionic.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Ionic.ToString方法的具体用法?C# Ionic.ToString怎么用?C# Ionic.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic
的用法示例。
在下文中一共展示了Ionic.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _Zip64_Over65534Entries
void _Zip64_Over65534Entries(Zip64Option z64option,
EncryptionAlgorithm encryption,
Ionic.Zlib.CompressionLevel compression)
{
// Emitting a zip file with > 65534 entries requires the use of ZIP64 in
// the central directory.
int numTotalEntries = _rnd.Next(4616)+65534;
//int numTotalEntries = _rnd.Next(461)+6534;
//int numTotalEntries = _rnd.Next(46)+653;
string enc = encryption.ToString();
if (enc.StartsWith("WinZip")) enc = enc.Substring(6);
else if (enc.StartsWith("Pkzip")) enc = enc.Substring(0,5);
string zipFileToCreate = String.Format("Zip64.ZF_Over65534.{0}.{1}.{2}.zip",
z64option.ToString(),
enc,
compression.ToString());
_testTitle = String.Format("ZipFile #{0} 64({1}) E({2}), C({3})",
numTotalEntries,
z64option.ToString(),
enc,
compression.ToString());
_txrx = TestUtilities.StartProgressMonitor(zipFileToCreate,
_testTitle,
"starting up...");
_txrx.Send("pb 0 max 4"); // 3 stages: AddEntry, Save, Verify
_txrx.Send("pb 0 value 0");
string password = Path.GetRandomFileName();
string statusString = String.Format("status Encrypt:{0} Compress:{1}...",
enc,
compression.ToString());
int numSaved = 0;
var saveProgress = new EventHandler<SaveProgressEventArgs>( (sender, e) => {
switch (e.EventType)
{
case ZipProgressEventType.Saving_Started:
_txrx.Send("status saving...");
_txrx.Send("pb 1 max " + numTotalEntries);
numSaved= 0;
break;
case ZipProgressEventType.Saving_AfterWriteEntry:
numSaved++;
if ((numSaved % 128) == 0)
{
_txrx.Send("pb 1 value " + numSaved);
_txrx.Send(String.Format("status Saving entry {0}/{1} ({2:N0}%)",
numSaved, numTotalEntries,
numSaved / (0.01 * numTotalEntries)
));
}
break;
case ZipProgressEventType.Saving_Completed:
_txrx.Send("status Save completed");
_txrx.Send("pb 1 max 1");
_txrx.Send("pb 1 value 1");
break;
}
});
string contentFormatString =
"This is the content for entry #{0}.\r\n\r\n" +
"AAAAAAA BBBBBB AAAAA BBBBB AAAAA BBBBB AAAAA\r\n"+
"AAAAAAA BBBBBB AAAAA BBBBB AAAAA BBBBB AAAAA\r\n";
_txrx.Send(statusString);
int dirCount= 0;
using (var zip = new ZipFile())
{
_txrx.Send(String.Format("pb 1 max {0}", numTotalEntries));
_txrx.Send("pb 1 value 0");
zip.Password = password;
zip.Encryption = encryption;
zip.CompressionLevel = compression;
zip.SaveProgress += saveProgress;
zip.UseZip64WhenSaving = z64option;
// save space when saving the file:
zip.EmitTimesInWindowsFormatWhenSaving = false;
zip.EmitTimesInUnixFormatWhenSaving = false;
// add files:
for (int m=0; m<numTotalEntries; m++)
{
if (_rnd.Next(7)==0)
{
string entryName = String.Format("{0:D5}", m);
zip.AddDirectoryByName(entryName);
dirCount++;
}
else
{
string entryName = String.Format("{0:D5}.txt", m);
if (_rnd.Next(12)==0)
{
string contentBuffer = String.Format(contentFormatString, m);
//.........这里部分代码省略.........
示例2: E
private void _ZOS_z64Over65534Entries
(Zip64Option z64option,
EncryptionAlgorithm encryption,
Ionic.Zlib.CompressionLevel compression)
{
TestContext.WriteLine("_ZOS_z64Over65534Entries hello: {0}",
DateTime.Now.ToString("G"));
int fileCount = _rnd.Next(14616) + 65536;
//int fileCount = _rnd.Next(146) + 5536;
TestContext.WriteLine("entries: {0}", fileCount);
var txrxLabel =
String.Format("ZOS #{0} 64({3}) E({1}) C({2})",
fileCount,
encryption.ToString(),
compression.ToString(),
z64option.ToString());
TestContext.WriteLine("label: {0}", txrxLabel);
string zipFileToCreate =
String.Format("ZOS.Zip64.over65534.{0}.{1}.{2}.zip",
z64option.ToString(), encryption.ToString(),
compression.ToString());
TestContext.WriteLine("zipFileToCreate: {0}", zipFileToCreate);
_txrx = TestUtilities.StartProgressMonitor(zipFileToCreate,
txrxLabel, "starting up...");
TestContext.WriteLine("generating {0} entries ", fileCount);
_txrx.Send("pb 0 max 3"); // 2 stages: Write, Count, Verify
_txrx.Send("pb 0 value 0");
string password = Path.GetRandomFileName();
string statusString = String.Format("status Encryption:{0} Compression:{1}",
encryption.ToString(),
compression.ToString());
_txrx.Send(statusString);
int dirCount = 0;
using (FileStream fs = File.Create(zipFileToCreate))
{
using (var output = new ZipOutputStream(fs))
{
_txrx.Send("test " + txrxLabel);
System.Threading.Thread.Sleep(400);
_txrx.Send("pb 1 max " + fileCount);
_txrx.Send("pb 1 value 0");
output.Password = password;
output.Encryption = encryption;
output.CompressionLevel = compression;
output.EnableZip64 = z64option;
for (int k = 0; k < fileCount; k++)
{
if (_rnd.Next(7) == 0)
{
// make it a directory
string entryName = String.Format("{0:D4}/", k);
output.PutNextEntry(entryName);
dirCount++;
}
else
{
string entryName = String.Format("{0:D4}.txt", k);
output.PutNextEntry(entryName);
// only a few entries are non-empty
if (_rnd.Next(18) == 0)
{
var block = TestUtilities.GenerateRandomAsciiString();
string content = String.Format("This is the content for entry #{0}.\n", k);
int n = _rnd.Next(4) + 1;
for (int j=0; j < n; j++)
content+= block;
byte[] buffer = System.Text.Encoding.ASCII.GetBytes(content);
output.Write(buffer, 0, buffer.Length);
}
}
if (k % 1024 == 0)
_txrx.Send(String.Format("status saving ({0}/{1}) {2:N0}%",
k, fileCount,
((double)k) / (0.01 * fileCount)));
else if (k % 256 == 0)
_txrx.Send("pb 1 value " + k);
}
}
}
_txrx.Send("pb 1 max 1");
_txrx.Send("pb 1 value 1");
_txrx.Send("pb 0 step");
System.Threading.Thread.Sleep(400);
TestContext.WriteLine("Counting entries ... " + DateTime.Now.ToString("G"));
_txrx.Send("status Counting entries...");
//.........这里部分代码省略.........