Ejemplo n.º 1
0
        public IActionResult DelFile(string names, string path)
        {
            path = rootPath + "\\" + path;
            string[] namearr = names.Split('/');
            PostJSON p       = new PostJSON();

            for (int i = 0; i < namearr.Length; i++)
            {
                if (!string.IsNullOrEmpty(namearr[i]))
                {
                    try
                    {
                        string npath = path + "\\" + namearr[i];
                        if (Directory.Exists(npath))
                        {
                            Directory.Delete(npath, true);
                        }
                        else
                        {
                            System.IO.File.Delete(npath);
                        }
                    }
                    catch (Exception ex)
                    {
                        p.notError  = false;
                        p.errorMsg += ex.ToString();
                    }
                }
            }
            return(Json(p));
        }
Ejemplo n.º 2
0
        public IActionResult GetUserFolder(string order, string path)
        {
            path = rootPath + "\\" + path;
            PostJSON p = new PostJSON();

            if (!Directory.Exists(rootPath))//如果用户根路径不存在则创建
            {
                Directory.CreateDirectory(rootPath);
            }
            if (path.IndexOf("..\\") == -1 && path.IndexOf("../") == -1)//如果包含上一级符号则屏蔽
            {
                if (Directory.Exists(path))
                {
                    folder folder = new folder();
                    folder = fileBLL.getFloder(path);
                    switch (order)
                    {
                    case "order_nameascending": folder.sortByName(); break;

                    case "order_sizeascending": folder.sortBySize(); break;

                    case "order_ModifiedDateascending": folder.sortByModifiedDate(); break;

                    case "order_CreatDateTimeascending": folder.sortByCreatDateTime(); break;

                    case "order_namedesc": folder.sortByNameDesc(); break;

                    case "order_sizedesc": folder.sortBySizeDesc(); break;

                    case "order_ModifiedDatedesc": folder.sortByModifiedDateDesc(); break;

                    case "order_CreatDateTimedesc": folder.sortByCreatDateTimeDesc(); break;

                    default:
                        break;
                    }
                    p.obj = folder;
                }
                else
                {
                    p.isError  = true;
                    p.errorMsg = "指定的目录不存在!";
                }
            }
            else
            {
                p.isError  = false;
                p.errorMsg = "不允许使用上一级符号";
            }
            return(Json(p));
        }
Ejemplo n.º 3
0
        public IActionResult Rename(string newName, string path, string oldName)
        {
            string   newPath = rootPath + "\\" + path + "\\" + newName; //原路径
            string   oldPath = rootPath + path + "\\" + oldName;        //原路径
            PostJSON p       = new PostJSON();

            try
            {
                System.IO.Directory.Move(oldPath, newPath);
            }
            catch (Exception ex)
            {
                p.isError  = true;
                p.errorMsg = ex.ToString();
            }

            return(Json(p));
        }