本文整理汇总了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;
//.........这里部分代码省略.........
示例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;
}
示例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();
}
}
示例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);
}
}