本文整理汇总了C#中Ionic.Send方法的典型用法代码示例。如果您正苦于以下问题:C# Ionic.Send方法的具体用法?C# Ionic.Send怎么用?C# Ionic.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ionic
的用法示例。
在下文中一共展示了Ionic.Send方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CleanDirectory
// [ClassCleanup()]
// public static void MyClassCleanup()
// {
// CleanDirectory(fodderDirectory, null);
// }
private static void CleanDirectory(string dirToClean, Ionic.CopyData.Transceiver txrx)
{
if (dirToClean == null) return;
if (!Directory.Exists(dirToClean)) return;
var dirs = Directory.GetDirectories(dirToClean, "*.*", SearchOption.AllDirectories);
if (txrx!=null)
txrx.Send("pb 1 max " + dirs.Length.ToString());
foreach (var d in dirs)
{
CleanDirectory(d, txrx);
if (txrx!=null)
txrx.Send("pb 1 step");
}
// Some of the files are marked as ReadOnly/System, and
// before deleting the dir we must strip those attrs.
var files = Directory.GetFiles(dirToClean, "*.*", SearchOption.AllDirectories);
if (txrx!=null)
txrx.Send("pb 1 max " + files.Length.ToString());
foreach (var f in files)
{
var a = File.GetAttributes(f);
// must do ReadOnly bit first - to allow setting other bits.
if ((a & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
a &= ~FileAttributes.ReadOnly;
File.SetAttributes(f, a);
}
if (((a & FileAttributes.Hidden) == FileAttributes.Hidden) ||
((a & FileAttributes.System) == FileAttributes.System))
{
a &= ~FileAttributes.Hidden;
a &= ~FileAttributes.System;
File.SetAttributes(f, a);
}
File.Delete(f);
if (txrx!=null)
txrx.Send("pb 1 step");
}
// Delete the directory with delay and retry.
// Sometimes I have a console window in the directory
// and I want it to not give up so easily.
int tries =0;
bool success = false;
do
{
try
{
Directory.Delete(dirToClean, true);
success = true;
}
catch
{
System.Threading.Thread.Sleep(600);
}
tries++;
} while (tries < 100 && !success);
}
示例2: DeleteOldFodderDirectories
private static void DeleteOldFodderDirectories( Ionic.CopyData.Transceiver txrx )
{
// Before creating the directory for the current run, Remove old directories.
// For some reason the test cleanup code tends to leave these directories??
string tempDir = System.Environment.GetEnvironmentVariable("TEMP");
var oldDirs = Directory.GetDirectories(tempDir, "*.SelectorTests");
if (oldDirs.Length > 0)
{
if (txrx != null)
{
txrx.Send("status deleting old directories...");
txrx.Send(String.Format("pb 0 max {0}", oldDirs.Length));
}
foreach (var dir in oldDirs)
{
CleanDirectory(dir, txrx);
if (txrx != null) txrx.Send("pb 0 step");
}
}
}