本文整理汇总了C#中System.IO.FileInfo.get_Name方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.get_Name方法的具体用法?C# FileInfo.get_Name怎么用?C# FileInfo.get_Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.get_Name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadReesters
public static void LoadReesters(ExtExternalProcessing processing, string fileName)
{
try
{
System.IO.FileInfo info = new System.IO.FileInfo(fileName);
if (!System.IO.File.Exists(info.get_FullName()))
{
throw new System.Exception(string.Format("Файл [{0}] не существует", fileName));
}
if (info.get_Extension().ToLower() == ".dbf")
{
System.Data.DataTable table = DALOdbc.ExecuteDataTable(DbfFormat.dBaseIV, info.get_DirectoryName(), "select * from " + info.get_Name());
if (table.Rows.get_Count() > 0)
{
System.Data.DataTable insertData = new System.Data.DataTable();
insertData.Columns.Add("processingId", System.Type.GetType("System.Int64"));
insertData.Columns.Add("field", System.Type.GetType("System.String"));
insertData.Columns.Add("statusId", System.Type.GetType("System.Int64"));
int id = FasetItem.FindByName(FasetsEnum.PaymentReestrStatus, "Загружен").Id;
foreach (System.Data.DataRow row in table.Rows)
{
System.Data.DataRow row2 = insertData.NewRow();
row2.set_Item("processingId", (long) processing.Id);
row2.set_Item("statusId", (int) id);
string str = "";
foreach (System.Data.DataColumn column in table.Columns)
{
string str2 = row.get_Item(column).ToString();
if (processing.Encoding != "")
{
System.Text.Encoding encoding = System.Text.Encoding.GetEncoding(processing.Encoding);
str2 = System.Text.Encoding.GetEncoding(0x4e3).GetString(encoding.GetBytes(str2));
}
str2 = str2.Replace(";", "").Replace("=", "");
str = str + column.get_Caption();
str = str + "=";
str = str + str2;
str = str + ';';
}
row2.set_Item("field", str);
insertData.Rows.Add(row2);
}
DALSql.BulkCopy("[ext].[ExternalProcessingFileRecords]", insertData);
}
}
if (info.get_Extension().ToLower() == ".txt")
{
System.Data.DataTable table3 = new System.Data.DataTable();
table3.Columns.Add("processingId", System.Type.GetType("System.Int64"));
table3.Columns.Add("field", System.Type.GetType("System.String"));
table3.Columns.Add("statusId", System.Type.GetType("System.Int64"));
System.Text.Encoding encoding3 = System.Text.Encoding.GetEncoding(0x362);
if (processing.Encoding != "")
{
encoding3 = System.Text.Encoding.GetEncoding(processing.Encoding);
}
System.IO.StreamReader reader = new System.IO.StreamReader(fileName, encoding3);
int num2 = FasetItem.FindByName(FasetsEnum.PaymentReestrStatus, "Загружен").Id;
while (!reader.get_EndOfStream())
{
string str3 = reader.ReadLine();
System.Data.DataRow row3 = table3.NewRow();
row3.set_Item("processingId", (long) processing.Id);
row3.set_Item("statusId", (int) num2);
row3.set_Item("field", str3);
table3.Rows.Add(row3);
}
DALSql.BulkCopy("[ext].[ExternalProcessingFileRecords]", table3);
}
if (info.get_Extension().ToLower() == ".csv")
{
System.Data.DataTable table4 = new System.Data.DataTable();
table4.Columns.Add("processingId", System.Type.GetType("System.Int64"));
table4.Columns.Add("field", System.Type.GetType("System.String"));
table4.Columns.Add("statusId", System.Type.GetType("System.Int64"));
System.IO.StreamReader reader2 = new System.IO.StreamReader(fileName, System.Text.Encoding.GetEncoding(0x4e3));
int num3 = FasetItem.FindByName(FasetsEnum.PaymentReestrStatus, "Загружен").Id;
while (!reader2.get_EndOfStream())
{
string str4 = reader2.ReadLine();
System.Data.DataRow row4 = table4.NewRow();
row4.set_Item("processingId", (long) processing.Id);
row4.set_Item("statusId", (int) num3);
row4.set_Item("field", str4);
table4.Rows.Add(row4);
}
DALSql.BulkCopy("[ext].[ExternalProcessingFileRecords]", table4);
}
if (info.get_Extension() == ".xml")
{
System.Data.DataTable table5 = new System.Data.DataTable();
table5.Columns.Add("processingId", System.Type.GetType("System.Int64"));
table5.Columns.Add("field", System.Type.GetType("System.String"));
table5.Columns.Add("statusId", System.Type.GetType("System.Int64"));
System.IO.StreamReader reader3 = new System.IO.StreamReader(fileName, System.Text.Encoding.GetEncoding(0x4e3));
int num4 = FasetItem.FindByName(FasetsEnum.PaymentReestrStatus, "Загружен").Id;
string str5 = reader3.ReadToEnd();
System.Data.DataRow row5 = table5.NewRow();
row5.set_Item("processingId", (long) processing.Id);
row5.set_Item("statusId", (int) num4);
//.........这里部分代码省略.........
示例2: Upload_Click
private void Upload_Click(object sender, System.EventArgs e)
{
ObjectList<RemitteePaymentOrder> remitteePaymentOrders = new ObjectList<RemitteePaymentOrder>();
ObjectList<Service> services = new ObjectList<Service>();
foreach (System.Windows.Forms.DataGridViewRow row in (System.Collections.IEnumerable) this.dgvRemitteePaymentOrders.Rows)
{
if ((row.Cells.get_Item("CheckColumn").get_Value() != null) && ((bool) row.Cells.get_Item("CheckColumn").get_Value()))
{
long id = (long) ((long) row.Cells.get_Item("id").get_Value());
remitteePaymentOrders.Add(ObjectWithId.FindById<RemitteePaymentOrder>(id));
}
}
services = this.selectServices.Services;
RemitteePaymentOrderUploading typeUse = (RemitteePaymentOrderUploading) this.bsUseType.get_Current();
if (typeUse == RemitteePaymentOrderUploading.Null)
{
AIS.SN.UI.Messages.ShowWarning("Выберете тип");
}
else
{
System.Data.DataSet set = RemitteePaymentOrder.Upload(remitteePaymentOrders, services, typeUse);
if (typeUse.Format != "DBF")
{
AIS.SN.UI.Messages.ShowWarning("Данный форма выгрузки пока не поддерживается");
}
else
{
this.sfdDBF.set_DefaultExt("dbf");
if (this.sfdDBF.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
System.IO.FileInfo info = new System.IO.FileInfo(this.sfdDBF.get_FileName());
string text1 = info.get_DirectoryName() + ((info.get_DirectoryName() == "") ? ((string) "") : ((string) @"\"));
DbFileFormat fileFormat = DbFileFormat.dBase3;
DBF.WriteToFile((System.Data.DataTable) set.Tables.get_Item(0), info.get_DirectoryName(), info.get_Name(), fileFormat, false, false);
AIS.SN.UI.Messages.ShowMessage("Выгрузка выполнена");
}
}
}
}
示例3: LoadReestersFromCity
public static void LoadReestersFromCity(MailExConfiguration mailExConfig)
{
PayPaymentSystem paymentSystem = PayPaymentSystem.FindAll().FindByProperty("Name", "Система \"Город\"");
string valueByName = Setting.GetValueByName("Взаимодействие с системой \"Город\"", "Код услуги");
if (string.IsNullOrEmpty(valueByName))
{
throw new System.ApplicationException("Не найдена константа кода услуги для системы \"Город\"");
}
string[] strArray = valueByName.Split((char[]) new char[] { ' ', ',', ';' }, System.StringSplitOptions.RemoveEmptyEntries);
System.Collections.Generic.List<int> allowedServices = new System.Collections.Generic.List<int>();
string[] strArray2 = strArray;
for (int i = 0; i < strArray2.Length; i = (int) (i + 1))
{
string str2 = strArray2[i];
int num = System.Convert.ToInt32(str2);
if (num > 0)
{
allowedServices.Add(num);
}
}
foreach (Reester248 reester in mailExConfig.GetReesters(new ReesterType[] { ReesterType.OUT_CASHPAY, ReesterType.OUT_CASHLESS, ReesterType.OUT_STORNO }, allowedServices, sourceFileName => !new System.IO.FileInfo(sourceFileName).get_Name().StartsWith("Z")))
{
try
{
SaveCityReesterToDatabase(reester, paymentSystem, AIS.SN.Model.DomainObjects.Organization.Null);
System.IO.FileInfo info = new System.IO.FileInfo(reester.FileName);
info.MoveTo(info.Directory + @"\Z_" + info.get_Name());
}
catch (System.Exception exception)
{
throw new System.ApplicationException("Не удалось сохранить файл реестра " + reester.FileName, exception);
}
}
}
示例4: m_FileLoadWorker_DoWork
private void m_FileLoadWorker_DoWork(object sender, DoWorkEventArgs e)
{
PayPaymentSystem paymentSystem = (this.bsPaymentSystems.get_Current() as PayPaymentSystem) ?? PayPaymentSystem.Null;
Organization agent = this.agentSelector.SelectedOrganizationOld ?? Organization.Null;
System.DateTime paymentOrderDate = (this.dbPaymentOrderDate == null) ? Constants.NullDate : this.dbPaymentOrderDate.Value;
System.DateTime paymentOrderPeriod = (this.dbPaymentOrderPeriod == null) ? Constants.NullDate : this.dbPaymentOrderPeriod.Value;
if (paymentOrderPeriod != Constants.NullDate)
{
paymentOrderPeriod = System.Convert.ToDateTime(string.Concat((object[]) new object[] { "01.", ((int) paymentOrderPeriod.get_Month()), ".", ((int) paymentOrderPeriod.get_Year()) }));
}
string selectedFileName = this.fileNameSelector.SelectedFileName;
if (!string.IsNullOrEmpty(selectedFileName))
{
if ((paymentSystem.Name == "Система Город") || (paymentSystem.Name == "Система \"Город\""))
{
ReesterType reeType = ReesterType.OUT_CASHPAY;
if (this.m_CashPaymentReesterRadio.get_Checked())
{
reeType = ReesterType.OUT_CASHPAY;
}
else if (this.m_CashlessPaymentReesterRadio.get_Checked())
{
reeType = ReesterType.OUT_CASHLESS;
}
else if (this.m_ReturnReesterRadio.get_Checked())
{
reeType = ReesterType.OUT_STORNO;
}
try
{
Reester248 fileRee = new Reester248(reeType, selectedFileName, System.Text.Encoding.GetEncoding(0x4e3));
PayReester reester2 = PayReester.SaveCityReesterToDatabase(fileRee, paymentSystem, agent);
System.IO.FileInfo info = new System.IO.FileInfo(fileRee.FileName);
info.MoveTo(info.Directory + @"\Z_" + info.get_Name());
e.set_Result(reester2);
return;
}
catch (System.Exception exception)
{
throw new System.ApplicationException("Файл реестра: " + selectedFileName, exception);
}
}
string name = string.Empty;
if (this.m_CashPaymentReesterRadio.get_Checked())
{
name = "Наличные платежи";
}
else if (this.m_CashlessPaymentReesterRadio.get_Checked())
{
name = "Безналичные платежи";
}
else if (this.m_ReturnReesterRadio.get_Checked())
{
name = "Возвраты платежей";
}
else if (this.m_ReturnCashlessReesterRadio.get_Checked())
{
name = "Возвраты безналичных платежей";
}
FasetItem @null = FasetItem.Null;
if (name != string.Empty)
{
@null = FasetItem.FindByName(FasetsEnum.PaymentsReestrType, name);
}
try
{
e.set_Result(PayReester.LoadReesterFromFile(selectedFileName, paymentSystem, agent, @null, paymentOrderDate, paymentOrderPeriod));
}
catch (System.Exception exception2)
{
throw new System.ApplicationException("Файл реестра: " + selectedFileName, exception2);
}
}
}
示例5: LoadReesterFromFile
public static PayReester LoadReesterFromFile(string sourceFileName, PayPaymentSystem paymentSystem, AIS.SN.Model.DomainObjects.Organization agent, FasetItem reesterType, System.DateTime paymentOrderDate, System.DateTime paymentOrderPeriod)
{
PayReester reester2;
try
{
System.IO.FileInfo sourceFile = new System.IO.FileInfo(sourceFileName);
if (!System.IO.File.Exists(sourceFile.get_FullName()))
{
throw new System.ApplicationException(string.Format("Файл {0} не существует", sourceFile));
}
PayReester payReester = new PayReester {
PaymentSystemId = paymentSystem.Id,
Organization = agent.ShortName,
OrganizationId = agent.Id,
Created = DALSql.GetDatabaseTime(),
Number = sourceFile.get_Name().Substring(0, (int) (sourceFile.get_Name().get_Length() - sourceFile.get_Extension().get_Length())),
StatusId = FasetItem.FindByName(FasetsEnum.PaymentReestrStatus, "Загружен").Id,
PaymentOrderDate = paymentOrderDate,
PaymentOrderPeriod = paymentOrderPeriod
};
if (reesterType != FasetItem.Null)
{
payReester.ReeTypeId = reesterType.Id;
}
payReester.SaveChanges();
if (sourceFile.get_Extension().ToUpper() == ".DBF")
{
LoadPaymentsFromDbf(payReester, sourceFile);
}
else if ((sourceFile.get_Extension().ToUpper() == ".TXT") && (paymentSystem.Name == "Безналичные платежи с зарплаты"))
{
LoadCashlessPaymentsFromSalary(payReester, sourceFile);
}
else
{
try
{
LoadPaymentsFromFile(payReester, sourceFile, paymentSystem.Encoding);
return payReester;
}
catch (System.Exception exception)
{
payReester.Delete();
throw new System.ApplicationException("Не удалось прочитать данные из файла " + sourceFile.get_Name() + " или выполнить обработку реестра. Содержание ошибки: " + exception.get_Message());
}
}
payReester.SaveChanges();
reester2 = payReester;
}
catch (System.Exception exception2)
{
throw new System.ApplicationException("Ошибка при загрузке файла реестра " + sourceFileName + ", возможно данный реестр уже был загружен", exception2);
}
return reester2;
}