public virtual void SaveFile(IFilePath fp) { using (new EntityCache(EntityCacheType.ForceNew)) { if (WeakFileReference) { return; } string sufix = CalculateSuffix(fp); if (!sufix.HasText()) { throw new InvalidOperationException("Sufix not set"); } fp.SetPrefixPair(GetPrefixPair(fp)); int i = 2; fp.Suffix = sufix; while (RenameOnCollision && File.Exists(fp.FullPhysicalPath())) { fp.Suffix = RenameAlgorithm(sufix, i); i++; } SaveFileInDisk(fp); } }
internal static void SaveFile(IFilePath fp) { using (new EntityCache(EntityCacheType.ForceNew)) { FileTypeAlgorithm alg = FileTypes.GetOrThrow(fp.FileType); if (alg.TakesOwnership) { string sufix = alg.CalculateSufix(fp); if (!sufix.HasText()) throw new InvalidOperationException("Sufix not set"); fp.SetPrefixPair(alg.GetPrefixPair(fp)); int i = 2; fp.Suffix = sufix; while (alg.RenameOnCollision && File.Exists(fp.FullPhysicalPath())) { fp.Suffix = alg.RenameAlgorithm(sufix, i); i++; } alg.SaveFileInDisk(fp); } } }
public virtual void MoveFile(IFilePath ofp, IFilePath fp) { if (WeakFileReference) { return; } System.IO.File.Move(ofp.FullPhysicalPath(), fp.FullPhysicalPath()); }
public virtual void SaveFileInDisk(IFilePath fp) { string?fullPhysicalPath = null; try { string path = Path.GetDirectoryName(fp.FullPhysicalPath()); fullPhysicalPath = path; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } File.WriteAllBytes(fp.FullPhysicalPath(), fp.BinaryFile); fp.BinaryFile = null !; } catch (IOException ex) { ex.Data.Add("FullPhysicalPath", fullPhysicalPath); ex.Data.Add("CurrentPrincipal", System.Threading.Thread.CurrentPrincipal.Identity.Name); throw; } }
public virtual byte[] ReadAllBytes(IFilePath path) { return(File.ReadAllBytes(path.FullPhysicalPath())); }
public virtual Stream OpenRead(IFilePath path) { return(File.OpenRead(path.FullPhysicalPath())); }
public static void SaveFileDefault(IFilePath fp) { string fullPhysicalPath = null; try { string path = Path.GetDirectoryName(fp.FullPhysicalPath()); fullPhysicalPath = path; if (!Directory.Exists(path)) Directory.CreateDirectory(path); File.WriteAllBytes(fp.FullPhysicalPath(), fp.BinaryFile); fp.BinaryFile = null; } catch (IOException ex) { ex.Data.Add("FullPhysicalPath", fullPhysicalPath); ex.Data.Add("CurrentPrincipal", System.Threading.Thread.CurrentPrincipal.Identity.Name); throw; } }