本文整理汇总了C#中System.IO.DirectoryInfo.get_Exists方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryInfo.get_Exists方法的具体用法?C# DirectoryInfo.get_Exists怎么用?C# DirectoryInfo.get_Exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.DirectoryInfo
的用法示例。
在下文中一共展示了DirectoryInfo.get_Exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFiles
public static ICollection GetFiles(bool blankLead, string templateFolder)
{
DirectoryInfo directoryInfo = new DirectoryInfo(templateFolder);
DataTable dataTable = new DataTable();
dataTable.get_Columns().Add(new DataColumn("File", typeof(string)));
dataTable.get_Columns().Add(new DataColumn("FullName", typeof(string)));
dataTable.get_Columns().Add(new DataColumn("URL", typeof(string)));
if (directoryInfo.get_Exists())
{
if (blankLead)
{
DataRow dataRow = dataTable.NewRow();
dataRow.set_Item(0, Constants.Unassigned);
dataTable.get_Rows().Add(dataRow);
}
FileSystemInfo[] files = directoryInfo.GetFiles("*.*");
if (files.Length > 0)
{
FileSystemInfo[] array = files;
for (int i = 0; i < array.Length; i++)
{
FileSystemInfo fileSystemInfo = array[i];
DataRow dataRow = dataTable.NewRow();
dataRow.set_Item(0, fileSystemInfo.get_Name().ToLower());
dataRow.set_Item(1, fileSystemInfo.get_FullName());
dataRow.set_Item(2, Constants.Config.TemplateFolder + "/" + fileSystemInfo.get_Name());
dataTable.get_Rows().Add(dataRow);
}
}
return new DataView(dataTable);
}
throw new CarConfigException("Template area does not exist");
}
示例2: CreateLog
private void CreateLog(bool useFileLog)
{
this.m_Logger = new ActionLog();
this.m_Logger.ExceptionLog = new ActionLog();
if (useFileLog)
{
string str = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), @"Система начислений за услуги ЖКХ\АРМ Печать извещений\Logs");
System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(str);
if (!info.get_Exists())
{
info.Create();
}
this.m_Logger.FileLogName = System.IO.Path.Combine(str, "Log " + System.DateTime.Now.ToString(this.m_Logger.TimeFormatString.Replace(':', '.'), System.Globalization.CultureInfo.InvariantCulture) + ".log");
}
this.m_Logger.UseFileLog = useFileLog;
}
示例3: Generate
//.........这里部分代码省略.........
report2.Dispose();
}
report = new NoticeReport(renderedNotices);
this.m_GeneratedReport = report;
}
if ((this.m_ThreadExceptions.Count > 0) || this.m_IsCancelled)
{
ex = null;
this.m_ThreadExceptions.TryDequeue(out ex);
this.AbortOperation(asyncOp, ex, (System.TimeSpan) (System.DateTime.Now - now));
}
else
{
if ((this.m_NoticeCache.get_Count() > 0) && (this.m_Exporter != null))
{
logger.Info("Экспорт по домам управляющих компаний");
int num9 = (int) ((this.m_Exporter.MaxPageCount * this.m_Template.AccountsInTemplate) / this.m_Template.PageCount);
CachedNoticeInfoComparer comparer = new CachedNoticeInfoComparer();
try
{
foreach (string str in this.m_NoticeCache.Keys)
{
this.m_NoticeCache[str].Sort(comparer);
logger.Info("Экспорт домов УК " + str);
for (int n = 0; n < this.m_NoticeCache[str].get_Count(); n = (int) (n + num9))
{
System.Text.StringBuilder builder = new System.Text.StringBuilder();
int num11 = this.m_NoticeCache[str].get_Count();
if (num11 != 0)
{
int maxPageCount = this.m_Exporter.MaxPageCount;
int num13 = (int) (num11 - (n + maxPageCount));
num13 = (num13 < 1) ? ((int) 0) : num13;
using (StiReport report3 = new StiReport())
{
report3.IsRendered = true;
report3.NeedsCompiling = false;
report3.RenderedPages.Clear();
System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(System.IO.Path.Combine(this.m_Exporter.DestinationPath, str));
if (!info.get_Exists())
{
info.Create();
}
string file = System.IO.Path.Combine(info.get_FullName(), string.Format("{0}_{1}.pdf", str, n / num9));
for (int num14 = n; num14 < (num11 - num13); num14 = (int) (num14 + 1))
{
System.IO.FileInfo info2 = new System.IO.FileInfo(this.m_NoticeCache[str].get_Item(num14).CacheFilePath);
if (info2.get_Exists())
{
byte[] bytes = System.IO.File.ReadAllBytes(info2.get_FullName());
StiReport report4 = new StiReport();
report4.LoadPackedDocument(bytes);
report4.ReportUnit = report3.ReportUnit;
foreach (StiPage page in report4.RenderedPages)
{
page.Report = report3;
page.Guid = System.Guid.NewGuid().ToString().Replace("-", "");
report3.RenderedPages.Add(page);
}
if (this.m_Exporter.DualPageExportMode && ((report4.RenderedPages.get_Count() % 2) != 0))
{
StiPage page2 = new StiPage(report3) {
IsRendered = true,
Orientation = report4.RenderedPages[0].Orientation,
Guid = System.Guid.NewGuid().ToString().Replace("-", "")
};
report3.RenderedPages.Add(page2);
}
builder.AppendLine(this.m_NoticeCache[str].get_Item(num14).FullAddress);
}
}
report3.ExportDocument(StiExportFormat.Pdf, file);
System.IO.File.WriteAllText(file + ".txt", builder.ToString());
}
}
}
}
logger.Info("Очистка дискового кэша");
System.IO.Directory.Delete(System.IO.Path.Combine(this.m_Exporter.DestinationPath, this.m_ExportCacheDirectoryName), true);
}
catch (System.Exception exception19)
{
ex = new NoticeGenerationException("Ошибка при экспорте извещений, сгруппированных по УК", exception19);
this.AbortOperation(asyncOp, ex, (System.TimeSpan) (System.DateTime.Now - now));
return;
}
}
System.TimeSpan timeSpent = (System.TimeSpan) (System.DateTime.Now - now);
logger.Info("Операция успешно завершена. Время выполнения " + timeSpent.ToString());
logger.Info("Всего отрендерено: " + ((int) this.m_TotalRendered));
if (asyncOp != null)
{
GenerationCompletedEventArgs args = new GenerationCompletedEventArgs(timeSpent, null, false, asyncOp.get_UserSuppliedState()) {
GeneratedReport = report
};
asyncOp.PostOperationCompleted(this.onCompletedDelegate, args);
}
this.Reset();
}
}
示例4: ReportGenerationThread
private void ReportGenerationThread()
{
Label_0000:
if (((this.m_ExportingNoticeCount <= 0) && (this.m_RenderedNoticeQueue.Count == 0)) && this.m_RenderedNoticeQueue.IsClosed)
{
logger.Info("Поток экспорта завершил выполнение");
}
else
{
if (this.m_RenderedNoticeQueue.Count == 0)
{
System.Threading.Thread.Sleep(10);
}
NoticeRenderedNotice notice = null;
if (this.m_RenderedNoticeQueue.TryDequeue(out notice))
{
System.Threading.Interlocked.Increment(ref this.m_ExportingNoticeCount);
NoticeReport noticeReport = new NoticeReport(notice);
lock (this.m_ReportGenerationSync)
{
if ((this.m_GenerationMode == GenerationMode.GenerateReport) && notice.HasResult)
{
this.m_NoticeReports.Add(noticeReport);
}
}
if (((this.m_Exporter != null) && (this.m_GenerationMode == GenerationMode.GenerateAndExport)) && notice.HasResult)
{
logger.Info("Экспорт извещений");
try
{
if (this.m_Exporter.GroupingMode == NoticeGroupingMode.HouseHolder)
{
string houseHolderName = notice.HouseHolderName;
char[] invalidFileChars = m_InvalidFileChars;
for (int i = 0; i < invalidFileChars.Length; i = (int) (i + 1))
{
char ch = invalidFileChars[i];
houseHolderName = houseHolderName.Replace(ch, ' ');
}
houseHolderName = houseHolderName.Trim();
if (!this.m_NoticeCache.ContainsKey(houseHolderName))
{
this.m_NoticeCache.Add(houseHolderName, new System.Collections.Generic.List<CachedNoticeInfo>());
}
System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(System.IO.Path.Combine(this.m_Exporter.DestinationPath, this.m_ExportCacheDirectoryName));
if (!info.get_Exists())
{
info.Create();
}
System.IO.DirectoryInfo info2 = new System.IO.DirectoryInfo(System.IO.Path.Combine(info.get_FullName(), houseHolderName));
if (!info2.get_Exists())
{
info2.Create();
}
string cacheFilePath = System.IO.Path.Combine(info2.get_FullName(), notice.AccountNumber);
CachedNoticeInfo info3 = new CachedNoticeInfo(cacheFilePath, notice.HouseAddressName, houseHolderName, notice.AddressName, notice.StreetName, notice.HouseSortValue, notice.FlatSortValue);
System.IO.File.WriteAllBytes(cacheFilePath, notice.PacketReport);
this.m_NoticeCache[houseHolderName].Add(info3);
}
else
{
this.m_Exporter.Export(noticeReport);
}
}
catch (System.Exception exception)
{
System.Threading.Interlocked.Decrement(ref this.m_ExportingNoticeCount);
NoticeGenerationException item = new NoticeGenerationException("Ошибка при экспорте извещений", exception);
this.m_ThreadExceptions.Enqueue(item);
return;
}
}
System.Threading.Interlocked.Decrement(ref this.m_ExportingNoticeCount);
}
goto Label_0000;
}
}
示例5: btExportPdf_Click
private void btExportPdf_Click(object sender, System.EventArgs e)
{
if (this.workerExportPdf.get_IsBusy())
{
this.btExportPdf.set_Text("Отменяется...");
this.btExportPdf.set_Enabled(false);
this.workerExportPdf.CancelAsync();
}
else
{
NoticeNoticeTemplate template = (this.bsNoticeTemplates.get_Current() as NoticeNoticeTemplate) ?? NoticeNoticeTemplate.Null;
if (this.bsNotices.get_Count() == 0)
{
Messages.ShowMessage("Для печати ничего не найдено");
}
else if (template == NoticeNoticeTemplate.Null)
{
Messages.ShowMessage("Не выбран шаблон");
}
else
{
template = ObjectWithId.FindById<NoticeNoticeTemplate>(template.Id);
if (string.IsNullOrEmpty(Settings.Default.NoticesExportFolder))
{
Messages.ShowMessage("Не выбран каталог выгрузки");
}
else
{
int num = System.Convert.ToInt32(this.nudPageCount.Value);
int accountsInTemplate = template.AccountsInTemplate;
int pageCount = template.PageCount;
int num4 = System.Convert.ToInt32(this.nudHousesPerDoc.Value);
if ((accountsInTemplate == 0) || (pageCount == 0))
{
Messages.ShowMessage("Не задано количество лицевых счетов на количество страниц в шаблоне");
}
else
{
System.IO.DirectoryInfo info;
int num5 = (int) ((num * accountsInTemplate) / pageCount);
try
{
System.IO.DirectoryInfo info2 = new System.IO.DirectoryInfo(Settings.Default.NoticesExportFolder);
if (!info2.get_Exists())
{
info2.Create();
}
info = new System.IO.DirectoryInfo(System.IO.Path.Combine(info2.get_FullName(), this.datePeriodShow.DateBegin.ToShortDateString().Replace('.', '-')));
if (!info.get_Exists())
{
info.Create();
}
}
catch (System.Security.SecurityException)
{
Messages.ShowError("Убедитесь, что текущий пользователь имеет права на запись в указанный каталог.");
return;
}
catch (System.IO.IOException exception)
{
Messages.ShowError("Ошибка при записи в каталог. " + System.Environment.get_NewLine() + exception.get_Message());
return;
}
ObjectList<NoticeNotice> noticesToBeFiltered = (ObjectList<NoticeNotice>) this.bsNotices.get_DataSource();
ObjectList<NoticeNotice> list2 = this.rbExportAccountNotices.get_Checked() ? noticesToBeFiltered : this.FilterNotices(noticesToBeFiltered, template);
System.Collections.Generic.Dictionary<string, System.Collections.Generic.IList<NoticeNotice>> dictionary = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.IList<NoticeNotice>>();
foreach (NoticeNotice notice in list2)
{
if (!dictionary.ContainsKey(notice.HouseHolderName))
{
dictionary.Add(notice.HouseHolderName, new ObjectList<NoticeNotice>());
}
dictionary[notice.HouseHolderName].Add(notice);
}
NoticeExportPdfParams @params = new NoticeExportPdfParams {
NoticeTemplate = template,
PeriodDirectory = info,
Notices = list2,
HouseHolderNotices = dictionary,
MaxNoticesPerDocument = num5,
MinHouseCount = num4
};
this.set_Cursor(System.Windows.Forms.Cursors.WaitCursor);
this.btExportPdf.set_Text("Отменить");
this.btnChooseExportDirectory.set_Enabled(false);
this.progressBarExportPdf.set_Visible(true);
this.workerExportPdf.RunWorkerAsync(@params);
}
}
}
}
}
示例6: workerExportPdf_DoWork
private void workerExportPdf_DoWork(object sender, DoWorkEventArgs e)
{
char[] chArray2;
int num12;
int num13;
object obj2;
char[] invalidFileNameChars = System.IO.Path.GetInvalidFileNameChars();
BackgroundWorker worker = sender as BackgroundWorker;
NoticeExportPdfParams @params = e.get_Argument() as NoticeExportPdfParams;
ObjectList<NoticeNotice> notices = @params.Notices;
int num = 0;
if (this.rbExportAccountNotices.get_Checked())
{
foreach (NoticeNotice notice in notices)
{
if (worker.get_CancellationPending())
{
e.set_Cancel(true);
break;
}
string str2 = string.IsNullOrEmpty(notice.HouseHolderName) ? ((string) "Неизвестная УК") : notice.HouseHolderName;
chArray2 = invalidFileNameChars;
num12 = 0;
while (num12 < chArray2.Length)
{
char ch = chArray2[num12];
str2 = str2.Replace(ch, ' ');
num12 = (int) (num12 + 1);
}
str2 = str2.Trim();
System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(System.IO.Path.Combine(@params.PeriodDirectory.get_FullName(), str2));
if (!info.get_Exists())
{
info.Create();
}
ObjectList<NoticeNotice> list2 = new ObjectList<NoticeNotice>();
list2.Add(notice);
try
{
using (System.Data.DataTable table = NoticeNotice.GetHeader(list2, this.cbHideClosedAccounts.get_Checked(), this.cbNoticeInformation.get_Checked()))
{
table.set_TableName("header");
using (System.Data.DataSet set = NoticeNotice.GetReport(list2, @params.NoticeTemplate.Sql))
{
if ((set.Tables.get_Count() < 2) || (set.Tables.get_Item(0).Rows.get_Count() == 0))
{
continue;
}
bool flag = false;
foreach (System.Data.DataRow row in table.Rows)
{
if (System.Convert.ToInt64(row.get_Item("id")) == notice.Id)
{
foreach (System.Data.DataRow row2 in set.Tables.get_Item(0).Rows)
{
if (System.Convert.ToInt64(row2.get_Item("id")) == notice.Id)
{
flag = true;
break;
}
}
}
}
if (!flag)
{
continue;
}
set.Tables.get_Item(0).set_TableName("pays");
set.Tables.get_Item(1).set_TableName("counter");
for (int i = 2; i < set.Tables.get_Count(); i = (int) (i + 1))
{
num13 = (int) (i - 1);
set.Tables.get_Item(i).set_TableName("data" + ((int) num13).ToString());
}
if (@params.NoticeTemplate.IdentityName == "Счет на оплату Ульяновск вариант 3")
{
if (set.Tables.get_Count() > 2)
{
set.Tables.get_Item(2).set_TableName("organizations");
}
if (set.Tables.get_Count() > 3)
{
set.Tables.get_Item(3).set_TableName("rates");
}
}
using (StiReport report = new StiReport())
{
report.LoadFromString(@params.NoticeTemplate.Template);
report.ReportCacheMode = StiReportCacheMode.Off;
report.Compile();
foreach (System.Data.DataTable table2 in set.Tables)
{
report.RegData(table2.get_TableName(), (System.Data.DataTable) table2);
}
report.RegData("header", (System.Data.DataTable) table);
string accountNumber = notice.AccountNumber;
string str5 = System.IO.Path.Combine(info.get_FullName(), accountNumber);
if (System.IO.File.Exists(str5 + ".pdf"))
{
int num5 = 1;
//.........这里部分代码省略.........