Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public static bool IsValidPath(this Je.IFssExpander e, string path)
 {
     return(!string.IsNullOrWhiteSpace(path) && path.All(c => !InvalidPathChars.Contains(c)));
 }
Ejemplo n.º 4
0
 public static bool IsValidFileName(this Je.IFssExpander e, string fileName)
 {
     return(!string.IsNullOrWhiteSpace(fileName) && fileName.All(c => !InvalidFileNameChars.Contains(c)));
 }
Ejemplo n.º 5
0
 public static FileWay TruFile(this Je.IFssExpander e, string fileName)
 {
     return(Je <FileWay> .Key(fileName.ToLower(), x => new FileWay(x)));
 }
Ejemplo n.º 6
0
 public static string TmpFile(this Je.IFssExpander e)
 {
     return($"{Guid.NewGuid()}.tmp");
 }
Ejemplo n.º 7
0
 public static string AppFile(this Je.IFssExpander e)
 {
     return(HttpContext.Current == null ? Process.GetCurrentProcess().MainModule.FileName : null);
 }
Ejemplo n.º 8
0
 public static string AppDir(this Je.IFssExpander e)
 {
     return(HttpContext.Current == null ? AppDomain.CurrentDomain.BaseDirectory : HttpContext.Current.Server.MapPath("~"));
 }