当前位置: 首页>>代码示例>>C#>>正文


C# FileInfo.LoadAs_ByteArray方法代码示例

本文整理汇总了C#中System.IO.FileInfo.LoadAs_ByteArray方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.LoadAs_ByteArray方法的具体用法?C# FileInfo.LoadAs_ByteArray怎么用?C# FileInfo.LoadAs_ByteArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileInfo的用法示例。


在下文中一共展示了FileInfo.LoadAs_ByteArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertToMMUnitsLoop

		/*
										private void ConvertToMMUnitsLoop(ButtonData parentButton, Object ParentObject, int level)
											{
											if (!EntriesPerLevel.ContainsKey(level))
												EntriesPerLevel[level] = 0;
											int sortOrder = 0;
											foreach (ButtonData buttonData in allOldButton
														.Where(whe => whe.ParentButton != null
														&& whe.ParentButton == parentButton).OrderBy(ord => ord.Row).ToArray())
												{
												MMUnit RootMMUnit = null;
												DbEntities.dbserver3.multimedia.rows.Page contentPage = null;
												if (level == 0)
													{
													RootMMUnit = Data.DbServer3.MultiMedia.MMUnits.FindOrLoad(buttonData.Id);
													if (RootMMUnit != null)
														{
														RootMMUnit.Delete();
														Data.DbServer3.MultiMedia.SaveKatabolic(new Object());
														Data.DbServer3.MultiMedia.AcceptChanges();
														}
													RootMMUnit = Data.DbServer3.MultiMedia.MMUnits.NewRow();
													RootMMUnit.Id = buttonData.Id;
													if (String.IsNullOrWhiteSpace(buttonData.NameId))
														buttonData.NameId = "Fahrplan";
													RootMMUnit.NameId = buttonData.NameId;
													RootMMUnit.Title = buttonData.Text;
													if (buttonData.EntryType == "Entry")
														RootMMUnit.MMUnitTyp = mmUnitTypForButtonData;
													if (buttonData.EntryType == "StaticEntry")
														RootMMUnit.MMUnitTyp = mmUnitTypForButtonDataStatic;
													RootMMUnit.Table.Rows.Add(RootMMUnit);
													RootMMUnit.PagingType = DirectPlayerPage;
													Data.DbServer3.MultiMedia.MMUnits.SaveChanges(new Object());
													Data.DbServer3.MultiMedia.MMUnits.AcceptChanges();
													}
												contentPage = Data.DbServer3.MultiMedia.Pages.NewRow();
												contentPage.Id = buttonData.Id;
												contentPage.SortOrder = ++sortOrder;
												contentPage.DiagnosticText = buttonData.NameId;
												if (level == 0)
													{
													contentPage.MMUnit = RootMMUnit;
													}
												else
													{
													contentPage.ParentPage = ParentObject as DbEntities.dbserver3.multimedia.rows.Page;
													}
												contentPage.Table.Rows.Add(contentPage);

												AddDrawingElements(buttonData, contentPage);
												Data.DbServer3.MultiMedia.SaveAnabolic(new Object());
												Data.DbServer3.MultiMedia.AcceptChanges();
												ConvertToMMUnitsLoop(buttonData, contentPage, level + 1);
												EntriesPerLevel[level]++;
												LoopCounter++;
												}

											}
								*/
		private void AddDrawingElements(ButtonData buttonData, DbEntities.dbserver3.multimedia.rows.Page page)
			{
			XmlDocument FileContent = null;
			if (!String.IsNullOrWhiteSpace(buttonData.FileName))
				{
				FileInfo fileInfo = new FileInfo(Path.Combine(@"\\webserver2\WPMediaSender\Haus\ButtonData",
					buttonData.FileName));
				if (fileInfo.Exists)
					{
					FileContent = new XmlDocument();
					FileContent.Load(fileInfo.FullName);
					}
				}
			if (!String.IsNullOrWhiteSpace(buttonData.ImageAfter))
				{
				String OldButtonRootDirectory = @"D:\WPMediaSender\AutoContent\ButtonData";
				FileInfo imageFileInfo = new FileInfo(Path.Combine(OldButtonRootDirectory, buttonData.ImageAfter));
				if (imageFileInfo.Exists)
					{
					Byte[] pictureBytes = imageFileInfo.LoadAs_ByteArray();
					String extension = Path.GetExtension(imageFileInfo.Name).Replace(".", "").ToLower();
					MMPicture picture = Data.DbServer3.MultiMedia.MMPictures.LoadOrCreate(pictureBytes,
						Path.GetFileNameWithoutExtension(imageFileInfo.Name), extension);
					Image newImage = Data.DbServer3.MultiMedia.Images.NewRow();
					newImage.Id = Guid.NewGuid();
					newImage.Page = page;
					newImage.DiagnosticText = $"Image zu {buttonData.NameId}";
					newImage.Extension = extension;
					newImage.SortOrder = 1;
					newImage.MMPicture = picture;
					newImage.Background = Colors.Transparent.ToString();
					newImage.BorderThickness = new Thickness(0).ToString();
					newImage.MarginThickness = new Thickness(0).ToString();
					newImage.Rotation = 0D;
					newImage.Table.Rows.Add(newImage);

					}
				}
			if (buttonData.LinkType == "ButtonPage")
				return;
//.........这里部分代码省略.........
开发者ID:heinzsack,项目名称:DEV,代码行数:101,代码来源:BannerConversion.cs

示例2: ImportData

		public bool ImportData()
			{
			foreach (string fileNameToImport in ListOfFileNamesToImport)
				{
				MaterialJPG newMaterialRow = Data.DbServer3.Blob.MaterialienJPG.NewRow();
				newMaterialRow.Id = Guid.NewGuid();
				newMaterialRow.FullFileNameToLoadFrom = fileNameToImport.ToLower();
				FileInfo fileInfo = new FileInfo(fileNameToImport);

				newMaterialRow.Value = fileInfo.LoadAs_ByteArray();
				newMaterialRow.HashCode = newMaterialRow.Value.Sha1Hash().ConvertTo_Hex();
				newMaterialRow.ValueThumb = newMaterialRow.Value.ConvertTo_Image()
					.ResizeToMaximum(300, 200).ConvertTo_JpgByteArray(80);

				MaterialJPG[] EqualEntries = Data.DbServer3.Blob.MaterialienJPG.Load_AllForHashCode(newMaterialRow.HashCode);
				if (EqualEntries.Length > 0)
					{
					MessageBox.Show("Es gibt einen Eintrag mit gleichem HashCode\r\n" +
					                "gespeichert ist derzeit der File:\r\n\""
					                + EqualEntries[0].FullFileNameToLoadFrom + "\"\r\n" +
					                "der folgende File soll importiert werden:\r\n\"" +
					                newMaterialRow.FullFileNameToLoadFrom + "\"\r\n" +
					                "Dieser Eintrag wird übersprungen!!");
					continue;

					}
				newMaterialRow.LastWriteFileTime = fileInfo.LastWriteTime;
				newMaterialRow.TypId = TypeOfMaterial;
                Guid foreignKey;
                if (IsOrtOrProjekt)
	                {
	                newMaterialRow.NameId = "Ort PictureTaken " + fileInfo.LastWriteTime.ToString();
					newMaterialRow.Description = "Ort_" + Path.GetFileName(fileNameToImport);
					newMaterialRow.WLaengeOrt = WordUpOrteHandlerModelInstance.SelectedOrt.WLaenge;
					newMaterialRow.WBreiteOrt = WordUpOrteHandlerModelInstance.SelectedOrt.WBreite;
	                foreignKey = WordUpOrteHandlerModelInstance.SelectedOrt.Id;
	                }
				else
					{
					newMaterialRow.NameId = "Projekt PictureTaken " + fileInfo.LastWriteTime.ToString();
					newMaterialRow.Description = "Projekt_" + Path.GetFileName(fileNameToImport);
					newMaterialRow.WLaengeOrt = ProjekteModellInstance.SelectedProjekt.Ort.WLaenge;
					newMaterialRow.WBreiteOrt = ProjekteModellInstance.SelectedProjekt.Ort.WBreite;
					foreignKey = ProjekteModellInstance.SelectedProjekt.Id;
					}
				newMaterialRow.LastLoadTime = DateTime.Now;
				newMaterialRow.PictureTakenDateTime = fileInfo.LastWriteTime;
				Data.DbServer3.Blob.MaterialienJPG.Rows.Add(newMaterialRow);
				Data.DbServer3.Blob.SaveAnabolic(true);
				Data.DbServer3.Blob.AcceptChanges();
				MaterialJPGForeignKeyConnector foreignConnector
					= Data.DbServer3.Blob.MaterialJPGForeignKeyConnectoren.NewRow();
				foreignConnector.Id = Guid.NewGuid();
				foreignConnector.Description = newMaterialRow.Description;
				foreignConnector.ForeignId = foreignKey;
				foreignConnector.JPGId = newMaterialRow.Id;
				foreignConnector.TypId = TypeOfMaterial;
				Data.DbServer3.Blob.MaterialJPGForeignKeyConnectoren.Rows.Add(foreignConnector);
				Data.DbServer3.Blob.SaveAnabolic();
				Data.DbServer3.Blob.AcceptChanges();
				}

			return true;
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:64,代码来源:ConnectedMaterialHandlerModell.cs

示例3: LoadMissingBlobsDoThumbDoHashing

		private void LoadMissingBlobsDoThumbDoHashing()
			{
			foreach (MaterialJPG entryWithoutFilledBlobs in
					Data.DbServer3.Blob.MaterialienJPG.Load_AllWithEmptyBlobs())
				{
				FileInfo fileInfo = new FileInfo(entryWithoutFilledBlobs.FullFileNameToLoadFrom);
				if (!fileInfo.Exists)
					continue;

				entryWithoutFilledBlobs.Value = fileInfo.LoadAs_ByteArray();
				entryWithoutFilledBlobs.HashCode = entryWithoutFilledBlobs.Value.Sha1Hash().ConvertTo_Hex();
				entryWithoutFilledBlobs.ValueThumb = entryWithoutFilledBlobs.Value.ConvertTo_Image()
					.ResizeToMaximum(300, 200).ConvertTo_JpgByteArray(80);

				Data.DbServer3.Blob.SaveAnabolic(true);
				entryWithoutFilledBlobs.Delete();
				Data.DbServer3.Blob.AcceptChanges();
                }
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:19,代码来源:ManagePicturesInDataBases.cs

示例4: StoreOutlookPictures

		public void StoreOutlookPictures()
			{
			//String TestInputFileName = "D:\\Temp\\BinaryFormatterInput.JPG";
			//String TestOutputFileName = "D:\\Temp\\BinaryFormatterOutput.JPG";
			//FileInfo fileInfoInput = new FileInfo(TestInputFileName);
			//FileInfo fileInfoOutput = new FileInfo(TestOutputFileName);
			//byte[] InputArray = fileInfoInput.LoadAs_ByteArray();
			//InputArray.SaveAs_Binary(fileInfoOutput);
			//return;
			foreach (Projekt projekt in Data.DbServer3.WordUp.Projekte.Find_PhasenCorrectProjekte("Planungen"))
				{
				String ProjektDirectory = DataWrapper.Instance.GetProjekteMaterialDirectory(projekt);
				if (!Directory.Exists(ProjektDirectory))
					Directory.CreateDirectory(ProjektDirectory);
				String PPTBildFileName = "PictureForPlenumsPPT.jpg";
				FileInfo fileInfo = new FileInfo(Path.Combine(ProjektDirectory, PPTBildFileName));
				String ExistingHash = String.Empty;
				if (fileInfo.Exists)
					{
					byte[] PictureBytes = fileInfo.LoadAs_ByteArray();
					ExistingHash = PictureBytes.Sha1Hash().ConvertTo_Hex();

					}
				MaterialJPG PreferedPPTPicture = GetPreferedPPTPicture(projekt);
				if (PreferedPPTPicture == null)
					continue;
				byte[] NewPictureBytes = PreferedPPTPicture.Get_Value();
                if (!String.IsNullOrEmpty(ExistingHash))
	                {
	                if (ExistingHash == PreferedPPTPicture.HashCode)
		                continue;
					fileInfo.Delete();
                    }
				NewPictureBytes.SaveTo_File(fileInfo);
                }
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:36,代码来源:ManagePicturesInDataBases.cs


注:本文中的System.IO.FileInfo.LoadAs_ByteArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。