Advertisement
yambroskin

Untitled

Dec 14th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. /--- это добавить вверх файла
  2. using System;
  3. using System.IO;
  4. using System.Net;
  5. using EleWise.ELMA.Files;
  6. using EleWise.ELMA.Services;
  7.  
  8.  
  9. /--- это функция для файла
  10.         public void UpdateCRC(BinaryFile bfile)
  11.         {
  12.             //путь до папки с файлами элмы
  13.             const string elmaPath = @"Z:\ELMA\Files";
  14.             var systemFileNhManager = Locator.GetServiceNotNull<SystemFileNHManager>();
  15.             //Console.WriteLine(bfile.Id);
  16.             SystemFile file = null; int id;
  17.             if (int.TryParse(bfile.Id, out id))
  18.             {
  19.                 file = systemFileNhManager.LoadFile(id);
  20.             }
  21.             else
  22.             {
  23.                 Guid uid;
  24.                 if (Guid.TryParse(bfile.Id, out uid))
  25.                 {
  26.                     file = systemFileNhManager.LoadFile(uid);
  27.                 }
  28.             }
  29.             if (file != null)
  30.             {
  31.                 var extension = Path.GetExtension(file.Name) ?? string.Empty;
  32.                 var path = Path.Combine(elmaPath, file.Id + extension);
  33.                 var fileInfo = new FileInfo(path); Console.WriteLine(path);
  34.                 if (fileInfo.Exists)
  35.                 {
  36.                     file.FileCrc = Crc32.GetCrcValue(fileInfo.FullName).ToString();
  37.                     file.FileSize = fileInfo.Length;
  38.                     systemFileNhManager.InsertFile(file);
  39.                 }
  40.             }
  41.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement