Ejemplo n.º 1
0
        internal static string []  ListDir(string RequestFile, string rootDir, string HostName, string port, bool ReplaceHost = true)
        {
            List <string> lst = new List <string>();

            if (!System.IO.Directory.Exists(RequestFile))
            {
                return(null);
            }

            string[] lstar  = System.IO.Directory.GetFiles(RequestFile);
            string[] lstdar = System.IO.Directory.GetDirectories(RequestFile);

            bool rootDirRequested = (RequestFile == rootDir);

            string host_et_port = HostName + ":" + port + "/";

            rootDir = rootDir.Replace("\\", "/");

            ///// parent
            if (!rootDirRequested)
            {
                string fx  = AppHelper.GoUpAsDirectory(RequestFile);
                string fx2 = fx.Replace("\\", "/");
                string fx3 = fx2.Replace(rootDir, "");
                string fx4 = WebServer.EncodeUrlChars(fx3);
                string fx5 = "http://" + host_et_port + fx4;
                string fx6 = fx5.Replace("%2F", "/");
                lst.Add(fx6);
            }
            else
            {
                lst.Add("");
            }

            foreach (string f in lstar) //files
            {
                string f2 = f.Replace("\\", "/");
                string f3 = f2.Replace(rootDir, "");
                string f4 = WebServer.EncodeUrlChars(f3);
                string f5 = "http://" + host_et_port + f4;
                string f6 = f5.Replace("%2F", "/");
                lst.Add(f6);
            }
            foreach (string f in lstdar) // dirs
            {
                string f2 = f.Replace("\\", "/");
                string f3 = f2.Replace(rootDir, "");
                string f4 = WebServer.EncodeUrlChars(f3);
                string f5 = "http://" + host_et_port + f4;
                string f6 = f5.Replace("%2F", "/");
                lst.Add(f6);
            }


            return(lst.ToArray());
        }
Ejemplo n.º 2
0
        internal static RykonFile[] ListDir(string RequestFile, string rootDir, string HostName, string port, bool ReplaceHost = true)
        {
            List <RykonFile> lstr = new List <RykonFile>();

            string[] lstar  = System.IO.Directory.GetFiles(RequestFile);
            string[] lstdar = System.IO.Directory.GetDirectories(RequestFile);

            bool   rootDirRequested = (RequestFile == rootDir);
            string host_et_port     = HostName + ":" + port + "/";

            rootDir = rootDir.Replace("\\", "/");

            ///// parent
            if (!rootDirRequested)
            {
                string fx  = AppHelper.GoUpAsDirectory(RequestFile);
                string fx2 = fx.Replace("\\", "/");
                string fx3 = fx2.Replace(rootDir, "");
                string fx4 = WebServer.EncodeUrlChars(fx3);
                string fx5 = "http://" + host_et_port + fx4;
                string fx6 = fx5.Replace("%2F", "/");

                RykonFile r = new RykonFile();
                r.IsDir    = false;
                r.Fullpath = fx;
                r.Webpath  = fx6;
                r.Name     = AppHelper.LastPeice(fx6, "/");
                lstr.Add(r);
            }
            else
            {
                lstr.Add(null);
            }


            foreach (string f in lstar) //files
            {
                string f2 = f.Replace("\\", "/");
                string f3 = f2.Replace(rootDir, "");
                string f4 = WebServer.EncodeUrlChars(f3);
                string f5 = "http://" + host_et_port + f4;
                string f6 = f5.Replace("%2F", "/");

                RykonFile r = new RykonFile();
                r.IsDir    = false;
                r.Fullpath = f;
                r.Webpath  = f6;
                r.Name     = AppHelper.LastPeice(f6, "/");
                lstr.Add(r);
            }
            foreach (string f in lstdar) // dirs
            {
                string f2 = f.Replace("\\", "/");
                string f3 = f2.Replace(rootDir, "");
                string f4 = WebServer.EncodeUrlChars(f3);
                string f5 = "http://" + host_et_port + f4;
                string f6 = f5.Replace("%2F", "/");

                RykonFile r = new RykonFile();
                r.IsDir    = true;
                r.Fullpath = f;
                r.Webpath  = f6 + "/";
                r.Name     = AppHelper.LastPeice(f6, "/");
                lstr.Add(r);
            }
            return(lstr.ToArray());
        }