public static bool RemoveFolder(this Je.IFssExpander e, string path) { if (!Directory.Exists(path)) { return(true); } int counter = 0; while (Directory.Exists(path)) { try { Directory.Delete(path); } catch { counter++; Thread.Sleep(500); } if (counter > 10) { break; } } return(!Directory.Exists(path)); }
public static bool RemoveFile(this Je.IFssExpander e, string fileName) { if (!System.IO.File.Exists(fileName)) { return(true); } int counter = 0; while (System.IO.File.Exists(fileName)) { try { System.IO.File.SetAttributes(fileName, FileAttributes.Normal); System.IO.File.Delete(fileName); } catch { counter++; Thread.Sleep(333); } if (counter > 10) { break; } } return(!System.IO.File.Exists(fileName)); }
public static bool IsValidPath(this Je.IFssExpander e, string path) { return(!string.IsNullOrWhiteSpace(path) && path.All(c => !InvalidPathChars.Contains(c))); }
public static bool IsValidFileName(this Je.IFssExpander e, string fileName) { return(!string.IsNullOrWhiteSpace(fileName) && fileName.All(c => !InvalidFileNameChars.Contains(c))); }
public static FileWay TruFile(this Je.IFssExpander e, string fileName) { return(Je <FileWay> .Key(fileName.ToLower(), x => new FileWay(x))); }
public static string TmpFile(this Je.IFssExpander e) { return($"{Guid.NewGuid()}.tmp"); }
public static string AppFile(this Je.IFssExpander e) { return(HttpContext.Current == null ? Process.GetCurrentProcess().MainModule.FileName : null); }
public static string AppDir(this Je.IFssExpander e) { return(HttpContext.Current == null ? AppDomain.CurrentDomain.BaseDirectory : HttpContext.Current.Server.MapPath("~")); }