public DirectoryFso(FileSystemObject parent, string name, string path = null)
     : base(parent, name, path)
 {
     SetBackupMode();
     if (BackupMode == BackupMode.Directory)
         Children = ConstructChildrenList(path ?? MappedPath);
 }
 public override void Store(byte[] bytes, FileSystemObject fso)
 {
     using (var byteStream = new MemoryStream(bytes, false))
     {
         Store(byteStream, fso);
     }
 }
        public override Stream GetStream(FileSystemObject fso)
        {
            var map = TryGetMap(fso.FullName);

            return map == null
                ? null
                : new MemoryStream(map.Bytes);
        }
        public override byte[] Get(FileSystemObject fso)
        {
            var map = TryGetMap(fso.FullName);

            return map == null
                ? null
                : map.Bytes;
        }
        public override void Store(Stream stream, FileSystemObject fso)
        {
            CreateFolder(fso.FolderName);

            using (var fs = new FileStream(fso.FullName, FileMode.Create, FileAccess.Write))
            {
                stream.WriteTo(fs);
            }
        }
 public override byte[] Get(FileSystemObject fso)
 {
     using (var stream = GetStream(fso))
     {
         return stream == null
             ? null
             : stream.ToBytes();
     }
 }
        public void ParsesValidWindowsName()
        {
            var test = new FileSystemObject("c:\\temp\\subdir1\\subdir2\\testfilename.txt");

            Assert.AreEqual(test.FileName, "testfilename");
            Assert.AreEqual(test.FileExtension, "txt");
            Assert.AreEqual(test.FileNameAndExtension, "testfilename.txt");
            Assert.AreEqual(test.FolderName, "c:\\temp\\subdir1\\subdir2");
            Assert.AreEqual(test.FullName, "c:\\temp\\subdir1\\subdir2\\testfilename.txt");
        }
        public void ParsesFileEndingWithDirectorySeparatorCorrectly()
        {
            var test = new FileSystemObject("/test-bucket-name/archive/subdir/testfile_hi.zip/");

            Assert.AreEqual(test.FileName, "testfile_hi");
            Assert.AreEqual(test.FileExtension, "zip");
            Assert.AreEqual(test.FileNameAndExtension, "testfile_hi.zip");
            Assert.AreEqual(test.FolderName, "/test-bucket-name/archive/subdir");
            Assert.AreEqual(test.FullName, "/test-bucket-name/archive/subdir/testfile_hi.zip");
        }
        public void ParsesValidUncName()
        {
            var test = new FileSystemObject("\\root\\subdir1\\subdir2\\testfile.zip");

            Assert.AreEqual(test.FileName, "testfile");
            Assert.AreEqual(test.FileExtension, "zip");
            Assert.AreEqual(test.FileNameAndExtension, "testfile.zip");
            Assert.AreEqual(test.FolderName, "\\root\\subdir1\\subdir2");
            Assert.AreEqual(test.FullName, "\\root\\subdir1\\subdir2\\testfile.zip");
        }
 public void ParseValidS3Name()
 {
     var test = new FileSystemObject("/test-bucket-name/archive/subdir/testfile_hi.zip");
     
     Assert.AreEqual(test.FileName, "testfile_hi");
     Assert.AreEqual(test.FileExtension, "zip");
     Assert.AreEqual(test.FileNameAndExtension, "testfile_hi.zip");
     Assert.AreEqual(test.FolderName, "/test-bucket-name/archive/subdir");
     Assert.AreEqual(test.FullName, "/test-bucket-name/archive/subdir/testfile_hi.zip");
 }
 public override void Copy(FileSystemObject thisFso, FileSystemObject targetFso, IFileStorageProvider targetProvider = null)
 {   // If targetProvider is null, copying within file system
     if (TreatAsLocalFileSystemProvider(targetProvider))
     {
         CopyInFileSystem(thisFso, targetFso);
         return;
     }
     
     // Copying across providers (from local file system to some other file provider)
     targetProvider.Store(thisFso, targetFso);
 }
        public override void Download(FileSystemObject thisFso, FileSystemObject downloadToFso)
        {
            var bytes = Get(thisFso);

            if (bytes == null)
            {
                throw new FileNotFoundException("File does not exist in memory provider", thisFso.FullName);
            }

            localFs.Store(bytes, downloadToFso);
        }
        public void ParseValidMixedFileSystemNameWindows()
        {
            var testFileAndPath = Path.Combine("\\test-bucket-name/archive", "subdir", "testfile_hi.zip");
            var test = new FileSystemObject(testFileAndPath);

            Assert.AreEqual(test.FileName, "testfile_hi");
            Assert.AreEqual(test.FileExtension, "zip");
            Assert.AreEqual(test.FileNameAndExtension, "testfile_hi.zip");
            Assert.AreEqual(test.FolderName, "\\test-bucket-name\\archive\\subdir");
            Assert.AreEqual(test.FullName, "\\test-bucket-name\\archive\\subdir\\testfile_hi.zip");
        }
Beispiel #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.InitTheExtensionImgDictionary();
     this.m_ConfigUploadDir = SiteConfig.SiteOption.UploadDir;
     this.m_CurrentDir      = BasePage.RequestString("Dir").Replace("..", string.Empty);
     this.m_UrlReferrer     = "FileManage.aspx?Dir=" + base.Server.UrlEncode(this.m_CurrentDir);
     if (!string.IsNullOrEmpty(this.m_ConfigUploadDir))
     {
         string path = "";
         if (!string.IsNullOrEmpty(this.m_CurrentDir) && (this.m_CurrentDir.LastIndexOf("/", StringComparison.Ordinal) > 0))
         {
             this.m_ParentDir = base.Server.UrlEncode(this.m_CurrentDir.Remove(this.m_CurrentDir.LastIndexOf("/", StringComparison.Ordinal), this.m_CurrentDir.Length - this.m_CurrentDir.LastIndexOf("/", StringComparison.Ordinal)));
         }
         path = this.m_ConfigUploadDir + this.m_CurrentDir + "/";
         this.LblCurrentDir.Text = path;
         path = base.Request.PhysicalApplicationPath + path;
         DirectoryInfo info = new DirectoryInfo(path);
         if (info.Exists)
         {
             if (string.IsNullOrEmpty(this.TxtSearchKeyword.Text))
             {
                 this.m_CurrentDirectoryInfo = FileSystemObject.GetDirectoryInfos(path, FsoMethod.All);
             }
             else
             {
                 string text = this.TxtSearchKeyword.Text;
                 if (!text.Contains("*"))
                 {
                     text = "*" + text + "*.*";
                 }
                 this.m_CurrentDirectoryInfo = FileSystemObject.SearchFiles(path, text);
             }
         }
     }
     else
     {
         this.PanContent.Visible = false;
         this.LitMessage.Text    = "请在网站配置中配置上传文件目录";
         this.LitMessage.Visible = true;
     }
     if (!this.Page.IsPostBack)
     {
         this.BindData();
     }
     this.BtnSearch.Click += new EventHandler(this.BtnSearch_Click);
 }
Beispiel #15
0
        public async Task <IActionResult> GetAsync(int id)
        {
            FileSystemObject fso = await _fsoService.GetFsoByIdAsync(id);

            User user = await _userService.GetUserFromPrincipalAsync(this.User);

            if (fso == null)
            {
                return(NotFound());
            }
            if (!await _fsoService.CheckOwnerAsync(fso, user))
            {
                return(Forbid());
            }

            return(Ok(_fsoService.ToDTO(fso)));
        }
Beispiel #16
0
        public bool IsExistXML(string LabelName)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(dirfilename);
            XmlNode nodeinfo = doc.SelectSingleNode("//NewDataSet/Table[LabelName='" + LabelName + "']");

            if (nodeinfo != null)
            {
                string filename = dir + nodeinfo["LabelCate"].InnerText + @"\" + LabelName + ".label";
                return(FileSystemObject.IsExist(filename, FsoMethod.File));
            }
            else
            {
                return(false);
            }
        }
        private int ExportDataToText(string filename, int groupId)
        {
            IList <string> userMailByGroupId = Users.GetUserMailByGroupId(groupId);

            if (userMailByGroupId.Count <= 0)
            {
                return(0);
            }
            StringBuilder builder = new StringBuilder();

            foreach (string str in userMailByGroupId)
            {
                builder.AppendLine(str);
            }
            FileSystemObject.WriteFile(filename, builder.ToString());
            return(userMailByGroupId.Count);
        }
Beispiel #18
0
        public bool Process(IBase baseObject, Facet facet, IGeneratorConfiguration generatorConfiguration)
        {
            var name         = baseObject.Name;
            var container    = (RestEntityContainer)baseObject;
            var variables    = container.Variables;
            var servicesPath = generatorConfiguration.ApplicationFolderHierarchy[IonicFileSystemType.WebAPIServicesRoot];
            var configPath   = FileSystemObject.PathCombine(servicesPath, "wwwroot", (string)container.Variables["title"] + "Config");
            var parentPath   = (string)variables["parentPath"];
            var parentObject = baseObject.EntityDictionary.Single(p => p.Value.GetCondensedID() == parentPath).Value;
            var rootObject   = (object)container.JsonRootObject;

            rootObject.SetDynamicMember("idBase", parentObject.GetCondensedID().ToBase64());

            WebAPIRestConfigJsonGenerator.GenerateJson(baseObject, configPath, generatorConfiguration);

            return(true);
        }
        public void Shopindex()
        {
            string IndexDir = SiteConfig.SiteOption.ShopTemplate;

            IndexDir = base.Request.PhysicalApplicationPath + SiteConfig.SiteOption.TemplateDir + "/" + IndexDir;
            IndexDir = IndexDir.Replace("/", @"\");
            if (!FileSystemObject.IsExist(IndexDir, FsoMethod.File))
            {
                Response.Write("[产生错误的可能原因:内容信息不存在或未开放!]");
            }
            else
            {
                string IndexHtml = FileSystemObject.ReadFile(IndexDir);
                IndexHtml = createBll.CreateHtml(IndexHtml, 0, 0, "0");
                Response.Write(IndexHtml);
            }
        }
        protected void RptFiles_ItemCommand(object source, CommandEventArgs e)
        {
            string p    = this.HdnPath.Value;
            string str2 = p + "/" + ((string)e.CommandArgument);

            if (e.CommandName == "DelFiles")
            {
                FileSystemObject.Delete(base.Request.PhysicalApplicationPath + str2.Replace("/", @"\"), FsoMethod.File);
                function.WriteSuccessMsg("文件成功删除", "../File/UploadFile.aspx?Dir=" + base.Server.UrlEncode(p));
            }
            if (e.CommandName == "DelDir")
            {
                base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
                FileSystemObject.Delete(base.Request.PhysicalApplicationPath + str2.Replace("/", @"\"), FsoMethod.Folder);
                function.WriteSuccessMsg("目录成功删除", "../File/UploadFile.aspx?Dir=" + base.Server.UrlEncode(p));
            }
        }
Beispiel #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckInstalled();
            string IndexDir = SiteConfig.SiteOption.IndexTemplate;

            IndexDir = base.Request.PhysicalApplicationPath + SiteConfig.SiteOption.TemplateDir + IndexDir;
            IndexDir = IndexDir.Replace("/", @"\");
            if (!FileSystemObject.IsExist(IndexDir, FsoMethod.File))
            {
                Response.Write("[产生错误的可能原因:您访问的内容信息不存在!]");
            }
            else
            {
                string IndexHtml = this.bll.CreateHtml(FileSystemObject.ReadFile(IndexDir), 0, 0);
                Response.Write(IndexHtml);
            }
        }
Beispiel #22
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.Page.IsPostBack)
     {
         B_Admin badmin = new B_Admin();
         badmin.CheckMulitLogin();
         if (!badmin.ChkPermissions("TemplateManage"))
         {
             function.WriteErrMsg("没有权限进行此项操作");
         }
         string str2        = base.Request.QueryString["Dir"];
         string TemplateDir = SiteConfig.SiteOption.TemplateDir;
         this.m_UrlReferrer = "TemplateManage.aspx?Dir=" + base.Server.UrlEncode(base.Request.QueryString["Dir"]);
         if (string.IsNullOrEmpty(str2))
         {
             this.lblDir.Text           = "/";
             this.DirPath               = TemplateDir;
             this.LitParentDirLink.Text = "<a disabled='disabled'>返回上一级</a>";
         }
         else
         {
             this.lblDir.Text = str2;
             this.DirPath     = TemplateDir + "/" + str2;
             if (str2.LastIndexOf("/") > 0)
             {
                 this.ParentDir = str2.Remove(str2.LastIndexOf("/"), str2.Length - str2.LastIndexOf("/"));
             }
             this.LitParentDirLink.Text = "<a href=\"TemplateManage.aspx?Dir=" + this.ParentDir + "\">返回上一级</a>";
         }
         this.AbsPath       = base.Request.PhysicalApplicationPath + TemplateDir + str2 + "/";
         this.AbsPath       = this.AbsPath.Replace("/", @"\");
         this.AbsPath       = this.AbsPath.Replace(@"\\", @"\");
         this.HdnPath.Value = this.AbsPath;
         try
         {
             DataTable fileList = FileSystemObject.GetDirectoryInfos(this.AbsPath, FsoMethod.All);
             this.repFile.DataSource = fileList;
             this.repFile.DataBind();
             this.Page.DataBind();
         }
         catch (Exception exception)
         {
             string message = exception.Message;
         }
     }
 }
Beispiel #23
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(base.Request.QueryString["ItemID"]))
     {
         int          ItemID   = DataConverter.CLng(base.Request.QueryString["ItemID"]);
         B_Content    bcontent = new B_Content();
         B_Model      bmode    = new B_Model();
         B_Node       bnode    = new B_Node();
         M_CommonData ItemInfo = bcontent.GetCommonData(ItemID);
         if (ItemInfo.IsNull)
         {
             Response.Write("[产生错误的可能原因:您访问的内容信息不存在!]");
         }
         M_ModelInfo modelinfo   = bmode.GetModelById(ItemInfo.ModelID);
         string      TempNode    = bnode.GetModelTemplate(ItemInfo.NodeID, ItemInfo.ModelID);
         string      TempContent = ItemInfo.Template;
         string      TemplateDir = modelinfo.ContentModule;
         if (!string.IsNullOrEmpty(TempContent))
         {
             TemplateDir = TempContent;
         }
         else
         {
             if (!string.IsNullOrEmpty(TempNode))
             {
                 TemplateDir = TempNode;
             }
         }
         if (string.IsNullOrEmpty(TemplateDir))
         {
             Response.Write("[产生错误的可能原因:该内容所属模型未指定模板!]");
         }
         else
         {
             TemplateDir = base.Request.PhysicalApplicationPath + SiteConfig.SiteOption.TemplateDir + TemplateDir;
             TemplateDir = TemplateDir.Replace("/", @"\");
             string ContentHtml = this.bll.CreateHtml(FileSystemObject.ReadFile(TemplateDir), 0, ItemID);
             Response.Write(ContentHtml);
         }
     }
     else
     {
         Response.Write("[产生错误的可能原因:您访问的内容信息不存在!]");
     }
 }
        public static string DeleteUnusefualFile(string content, string defaultPicUrl, string uploadFiles)
        {
            string file = "";

            if (uploadFiles.IndexOf('|') > 1)
            {
                string[] strArray = uploadFiles.Split(new string[] { "|" }, StringSplitOptions.None);
                uploadFiles = "";
                foreach (string str2 in strArray)
                {
                    if ((content.IndexOf(str2, StringComparison.Ordinal) <= 0) && (str2 != defaultPicUrl))
                    {
                        file = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir) + str2).Replace("/", @"\");
                        if (FileSystemObject.IsExist(file, FsoMethod.File))
                        {
                            FileSystemObject.Delete(file, FsoMethod.File);
                            HttpContext.Current.Response.Write("<li>" + str2 + "在项目中没有用到,也没有被设为首页图片,所以已经被删除!</li>");
                        }
                        else if (string.IsNullOrEmpty(uploadFiles))
                        {
                            uploadFiles = str2;
                        }
                        else
                        {
                            uploadFiles = uploadFiles + "|" + str2;
                        }
                    }
                }
            }
            else if ((content.IndexOf(uploadFiles, StringComparison.Ordinal) <= 0) && (uploadFiles != defaultPicUrl))
            {
                file = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir) + uploadFiles).Replace("/", @"\");
                if (FileSystemObject.IsExist(file, FsoMethod.File))
                {
                    FileSystemObject.Delete(file, FsoMethod.File);
                    HttpContext.Current.Response.Write("<li>" + uploadFiles + "在项目中没有用到,也没有被设为首页图片,所以已经被删除!</li>");
                }
                uploadFiles = "";
            }
            if (string.IsNullOrEmpty(uploadFiles))
            {
                uploadFiles = defaultPicUrl;
            }
            return(uploadFiles);
        }
Beispiel #25
0
        public void CreateIndex()
        {
            string IndexDir = SiteConfig.SiteOption.IndexTemplate;

            IndexDir = this.SitePhyPath + SiteConfig.SiteOption.TemplateDir + IndexDir;
            IndexDir = IndexDir.Replace("/", @"\");
            string IndexHtml = this.bll.CreateHtml(FileSystemObject.ReadFile(IndexDir), 0, 0);
            string objindex  = this.SitePhyPath + @"\" + "index.html";

            if (FileSystemObject.IsExist(objindex, FsoMethod.File))
            {
                FileSystemObject.WriteFile(objindex, IndexHtml);
            }
            else
            {
                FileSystemObject.WriteFile(objindex, IndexHtml);
            }
        }
Beispiel #26
0
        public async Task <IActionResult> RenameAsync([FromBody] FileSystemObject request)
        {
            FileSystemObject fso = await _fsoService.GetFsoByIdAsync(request.Id);

            User user = await _userService.GetUserFromPrincipalAsync(this.User);

            if (fso == null)
            {
                return(NotFound());
            }
            if (!await _fsoService.CheckOwnerAsync(fso, user))
            {
                return(Forbid());
            }
            await _fsoService.UpdateFsoAsync(request);

            return(Ok());
        }
Beispiel #27
0
    //--------------Tools
    public void BindDP(string vpath)
    {
        string    ppath = Server.MapPath(vpath);
        DataTable dt    = FileSystemObject.GetDirectoryAllInfos(ppath, FsoMethod.File);

        dt.DefaultView.RowFilter = "rname Like '%.html'";
        dt = dt.DefaultView.ToTable(false, "rname");
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            dt.Rows[i]["rname"] = dt.Rows[i]["rname"].ToString().Replace(ppath, "").Replace(@"\", "/");
        }
        IndexTemplate_DP.DataSource = dt;
        IndexTemplate_DP.DataBind();
        ShopTemplate_DP.DataSource = dt;
        ShopTemplate_DP.DataBind();
        IndexTemplate_DP.Items.Insert(0, new ListItem("未指定", ""));
        ShopTemplate_DP.Items.Insert(0, new ListItem("未指定", ""));
    }
Beispiel #28
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (this.Page.IsValid)
     {
         if (this.Hdnmethod.Value == "add")
         {
             this.FilePath = this.HdnFilePath.Value + @"\" + this.TxtFilename.Text;
             FileSystemObject.WriteFile(this.FilePath, this.textContent.Text);
         }
         if (this.Hdnmethod.Value == "append")
         {
             this.FilePath = this.HdnFilePath.Value;
             FileSystemObject.WriteFile(this.FilePath, this.textContent.Text);
         }
         string sPath = this.HdnShowPath.Value.Replace("/", "");
         base.Response.Redirect("TemplateManage.aspx?Dir=" + sPath);
     }
 }
Beispiel #29
0
 public static void DeleteJS(string id)
 {
     if (!string.IsNullOrEmpty(id))
     {
         string[]    strArray         = id.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
         string      advertisementDir = SiteConfig.SiteOption.AdvertisementDir;
         HttpContext current          = HttpContext.Current;
         if (current != null)
         {
             advertisementDir = current.Server.MapPath("~/" + advertisementDir);
         }
         for (int i = 0; i < strArray.Length; i++)
         {
             ADZoneInfo adZoneById = GetAdZoneById(DataConverter.CLng(strArray[i]));
             FileSystemObject.Delete(VirtualPathUtility.AppendTrailingSlash(advertisementDir) + adZoneById.ZoneJSName, FsoMethod.File);
         }
     }
 }
Beispiel #30
0
        public string[] GetFileSize()
        {
            int count = this.zoneConfig.Count;

            string[] strArray = new string[count];
            for (int i = 0; i < (count); i++)
            {
                if (FileSystemObject.IsExist(GetJsTemplatePath() + this.GetTemplateName(i), FsoMethod.File))
                {
                    strArray[i] = FileSystemObject.GetFileSize(GetJsTemplatePath() + this.GetTemplateName(i));
                }
                else
                {
                    strArray[i] = "0.0KB";
                }
            }
            return(strArray);
        }
Beispiel #31
0
    /// <summary>
    /// 每个页面必须实现,用于将模板解析为html
    /// </summary>
    public virtual string TemplateToHtml(string templateUrl)
    {
        string html        = "";
        string vpath       = (SiteConfig.SiteOption.TemplateDir + "/" + templateUrl);
        string TemplateDir = function.VToP(vpath);

        if (!File.Exists(TemplateDir))
        {
            return("[产生错误的可能原因:(" + vpath + ")文件不存在]");
        }
        html = FileSystemObject.ReadFile(TemplateDir);
        html = bll.CreateHtml(html, Cpage, ItemID, "1");
        if (SiteConfig.SiteOption.IsSensitivity == 1)
        {
            html = B_Sensitivity.Process(html);
        }
        return(html);
    }
        protected void MyBind()
        {
            M_UserInfo        mu    = buser.GetLogin();
            M_Design_SiteInfo sfMod = sfBll.SelReturnModel(SiteID);

            sfBll.CheckAuthEx(sfMod, mu);
            string pdir = function.VToP(VDir);

            if (!Directory.Exists(pdir))
            {
                function.WriteErrMsg("[" + VDir + "]目录不存在");
            }
            DataTable filesDT = FileSystemObject.GetDirectoryInfos(pdir, FsoMethod.All);

            RPT.DataSource = filesDT;
            RPT.DataBind();
            GetBread();
        }
Beispiel #33
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Call.SetBreadCrumb(Master, "<li>工作台</li><li>系统设置</li><li>方案管理</li><li class=\"active\">发布当前站点方案</li>");
     if (!IsPostBack)
     {
         string    tempdir  = SiteConfig.SiteOption.TemplateDir;
         string[]  temparr  = tempdir.Split(new string[] { @"/" }, StringSplitOptions.None);
         string    template = SiteConfig.SiteMapath() + temparr[1];
         DataTable newtable = FileSystemObject.GetDirectorySmall(template);
         if (newtable != null && newtable.Rows.Count > 0)
         {
             for (int i = 0; i < newtable.Rows.Count; i++)
             {
                 this.tempdirlist.Items.Add(new ListItem(newtable.Rows[i]["name"].ToString(), newtable.Rows[i]["name"].ToString()));
             }
         }
     }
 }
        private FileSystemObject SelectOneDirectoryInfo(DirectoryInfo info)
        {
            if (info == null)
            {
                return(null);
            }

            FileSystemObject obj = SelectOneFileSystemInfo(info);

            obj.IsFile = false;

            try
            {
                obj.HasChilds = (Directory.GetDirectories(info.FullName).Length + Directory.GetFiles(info.FullName).Length) > 0;
            }

            return(obj);
        }
        protected void GridView1_RowCommand(object Sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.ToLower() == "dir")
            {
                BindData(e.CommandArgument.ToString());
            }

            if (e.CommandName.ToLower() == "del")
            {
                string           msg = String.Empty;
                FileSystemObject fso = new FileSystemObject()
                {
                    FullName = e.CommandArgument.ToString()
                };
                FileManager.Delete(fso, out msg);
                BindData(Label_ServerPhysicalPath.Text);
            }
        }
Beispiel #36
0
        /// <summary>
        /// 获得内容生成路径
        /// </summary>
        /// <param name="NodeID"></param>
        /// <param name="GeneralID"></param>
        /// <returns></returns>
        private string GetPath(string NodeID, int GeneralID)
        {
            M_Node       Nodeinfo      = nll.SelReturnModel(DataConverter.CLng(NodeID));
            string       ContentFileEx = GetNodeContentEx(Nodeinfo);//内容页文件扩展名
            string       ContentRoot   = "";
            M_CommonData Cdata         = cll.GetCommonData(GeneralID);

            int ContentPageHtmlRule = Nodeinfo.ContentPageHtmlRule;//内容页文件名规则

            switch (ContentPageHtmlRule)
            {
            case 0:
                string filepath = MakeHtmlFile(Nodeinfo) + "/" + Cdata.CreateTime.Year + "/" + Cdata.CreateTime.Month + "/" + Cdata.CreateTime.Day;
                if (!FileSystemObject.IsExist(filepath, FsoMethod.Folder))
                {
                    FileSystemObject.CreateFileFolder(filepath);
                }
                ContentRoot = "/" + Cdata.CreateTime.Year + "/" + Cdata.CreateTime.Month + "/" + Cdata.CreateTime.Date.ToShortDateString() + "/" + Cdata.GeneralID.ToString();
                break;

            case 1:
                filepath = MakeHtmlFile(Nodeinfo) + "/" + Cdata.CreateTime.Year + "-" + Cdata.CreateTime.Month;
                if (!FileSystemObject.IsExist(filepath, FsoMethod.Folder))
                {
                    FileSystemObject.CreateFileFolder(filepath);
                }
                ContentRoot = filepath + Cdata.GeneralID.ToString();
                break;

            case 2:
                ContentRoot = "/" + Cdata.GeneralID.ToString();
                break;

            case 3:
                filepath = MakeHtmlFile(Nodeinfo) + "/" + Cdata.CreateTime.Year + Cdata.CreateTime.Month + Cdata.CreateTime.Day;
                if (!FileSystemObject.IsExist(filepath, FsoMethod.Folder))
                {
                    FileSystemObject.CreateFileFolder(filepath);
                }
                ContentRoot = "/" + Cdata.CreateTime.Year + Cdata.CreateTime.Month + Cdata.CreateTime.Day + "/" + Cdata.Title;
                break;
            }
            return(ContentRoot + "." + GetNodeContentEx(Nodeinfo));
        }
Beispiel #37
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        this.m_FileExtArr = "jpg|gif|png|bmp|jpeg|swf|rar";
        string str3       = "";
        string foldername = "";
        string filename   = "";
        string str2       = "";

        System.Web.UI.WebControls.FileUpload upload = (System.Web.UI.WebControls.FileUpload) this.FindControl("FileUpload1");
        StringBuilder builder2 = new StringBuilder();

        if (upload.HasFile)
        {
            str2 = Path.GetExtension(upload.FileName).ToLower();
            if (!this.CheckFilePostfix(str2.Replace(".", "")))
            {
                builder2.Append("照片" + upload.FileName + "不符合图片扩展名规则" + this.m_FileExtArr + @"\r\n");
            }
            else
            {
                if (((int)upload.FileContent.Length) > (20 * 0x400))
                {
                    builder2.Append("照片" + upload.FileName + "大小超过20" + @"KB\r\n");
                }
                else
                {
                    str3       = DataSecurity.MakeFileRndName();
                    foldername = base.Request.PhysicalApplicationPath + (VirtualPathUtility.AppendTrailingSlash("/Uploadfiles/Source")).Replace("/", "\\");// + this.FileSavePath()
                    filename   = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current) + str3 + str2;
                    upload.SaveAs(filename);
                    builder2.Append("照片" + upload.FileName + @"上传成功\r\n");
                    this.txtpic.Text = "UpLoadFiles/Source/" + str3 + str2;
                    showphoto.Src    = "../../UpLoadFiles/Source/" + str3 + str2;
                }
            }
        }
        //if (builder2.Length > 0)
        //{
        //    Response.Write("<script language=\"javascript\" type=\"text/javascript\">alert('" + builder2.ToString() + "');/script>");
        //    Page.Response.Redirect("Advertisement.aspx");
        //    this.txtpic.Text = "UpLoadFiles/Plus/" + str3 + str2;

        //}
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            B_Admin badmin = new B_Admin();

            if (!IsPostBack)
            {
                Call.SetBreadCrumb(Master, "<li><a href='" + CustomerPageAction.customPath2 + "I/Main.aspx'>" + Resources.L.工作台 + "</a></li><li><a href='ContentManage.aspx'>" + Resources.L.内容管理 + "</a></li><li><a href='CreateHtmlContent.aspx'>" + Resources.L.生成发布 + "</a></li><li class='active'><a href='" + Request.RawUrl + "'>" + Resources.L.内容生成管理 + "</a></li>");
                //直接浏览
                if (ContentID > 0)
                {
                    string htmllink = bll.GetCommonData(ContentID).HtmlLink;
                    if (htmllink != "")
                    {
                        htmllink = "../../" + SiteConfig.SiteOption.GeneratedDirectory + htmllink;
                        Response.Redirect(htmllink);
                    }
                }
                //删除文件
                if (GeneralID > 0)
                {
                    string htmllink = bll.GetCommonData(GeneralID).HtmlLink;
                    if (!string.IsNullOrEmpty(htmllink))
                    {
                        string fleex = "." + htmllink.Split('.')[1];
                        FileSystemObject.Delete(Server.MapPath(htmllink), FsoMethod.File);
                        string HtmlLinkurl = htmllink.Replace(GeneralID + fleex, "");
                        //删除页面与其的分页
                        DirectoryInfo di = new DirectoryInfo(Server.MapPath(HtmlLinkurl));
                        FileInfo[]    ff = di.GetFiles(GeneralID + "_" + "*");
                        if (ff.Length != 0)
                        {
                            foreach (FileInfo fi in ff)
                            {
                                fi.Delete();
                            }
                        }
                        bll.UpdateCreate1(GeneralID);
                        function.WriteSuccessMsg(Resources.L.恭喜您删除成功 + "!", "ListHtmlContent.aspx");
                    }
                }
                this.BindOrder();
                MyBind();
            }
        }
Beispiel #39
0
        private void MyBind()
        {
            //---读取系统资源
            int       psize = 18, pcount = 0;
            DataTable dt = new DataTable();

            switch (ZType)
            {
            case "sysimg":
            {
                dt             = resBll.Search("", "bk_h5", "img", "", "", Style);
                RPT.DataSource = PageCommon.GetPageDT(psize, CPage, dt, out pcount);
                RPT.DataBind();
                Page_Lit.Text     = PageCommon.CreatePageHtml(pcount, CPage);
                empty_div.Visible = dt.Rows.Count < 1;
                //-------------------
                string[] styleArr = ("全部," + resMod.StyleArr).Split(',');
                foreach (string name in styleArr)
                {
                    string css = name.Equals(Style) ? "active" : "";
                    style_ul.InnerHtml += "<li class=\"style_li " + css + "\" onclick=\"getto('" + HttpUtility.UrlEncode(name) + "');\">" + name + "</li>";
                }
            }
            break;

            case "myimg":
            {
                //---读取用户上传的资源
                myimg_div.Visible  = true;
                sysimg_div.Visible = false;
                var    mu   = buser.GetLogin();
                string path = function.VToP("/UploadFiles/User/" + mu.UserName + mu.UserID);
                if (FileSystemObject.IsExist(path, FsoMethod.Folder))
                {
                    dt = FileSystemObject.SearchImg(path);
                }
                Myimg_RPT.DataSource = PageCommon.GetPageDT(psize, CPage, dt, out pcount);
                Myimg_RPT.DataBind();
                ImgPage_Lit.Text = PageCommon.CreatePageHtml(pcount, CPage);
                emptyimg.Visible = dt.Rows.Count < 1;
            }
            break;
            }
        }
Beispiel #40
0
        private bool CreateAndCheckFolderPermission(SpecialInfo specialInfo)
        {
            string file = VirtualPathUtility.AppendTrailingSlash(this.PhysicalApplicationPath) + VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + specialInfo.SpecialDir;

            if (!FileSystemObject.IsExist(file, FsoMethod.Folder))
            {
                try
                {
                    FileSystemObject.Create(file, FsoMethod.Folder);
                }
                catch
                {
                    string errMsg = "专题ID:" + specialInfo.SpecialId.ToString() + "  " + specialInfo.SpecialName + " 生成失败! 失败原因:请检查服务器是否给网站" + SiteConfig.SiteOption.CreateHtmlPath + "文件夹写入权限!";
                    this.ErrorLog(errMsg);
                    return(false);
                }
            }
            return(true);
        }
        public async Task <IActionResult> OnPostAsync(string keyword, int dirId)
        {
            CurrentDir = _context.FileSystemObjects.FirstOrDefault(d => d.Id == dirId);
            if (CurrentDir != null)
            {
                ViewData["ReturnId"] = CurrentDir.Id;
                if (keyword != null)
                {
                    await searchDir(dirId);

                    filterResults(keyword);
                }
                return(Page());
            }
            else
            {
                return(RedirectToPage("./Index"));
            }
        }
        protected void BindData()
        {
            DataView defaultView = FileSystemObject.GetDirectoryInfos(this.currentDirectory, FsoMethod.All).DefaultView;

            this.Pager.RecordCount = defaultView.Count;
            int num  = (this.Pager.CurrentPageIndex - 1) * this.Pager.PageSize;
            int num2 = num + this.Pager.PageSize;
            List <DataRowView> list = new List <DataRowView>();

            for (int i = num; i < num2; i++)
            {
                if (i < defaultView.Count)
                {
                    list.Add(defaultView[i]);
                }
            }
            this.EgvFiles.DataSource = list;
            this.EgvFiles.DataBind();
        }
        private bool CreateAndCheckFolderPermission(SpecialCategoryInfo categoryInfo)
        {
            string file = VirtualPathUtility.AppendTrailingSlash(this.PhysicalApplicationPath) + VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.CreateHtmlPath) + categoryInfo.SpecialCategoryDir;

            if (!FileSystemObject.IsExist(file, FsoMethod.Folder))
            {
                try
                {
                    FileSystemObject.Create(file, FsoMethod.Folder);
                }
                catch
                {
                    string errMsg = string.Concat(new object[] { "专题类别ID为:", categoryInfo.SpecialCategoryId, "  ", categoryInfo.SpecialCategoryName, " 生成失败! 失败原因:请检查服务器是否给网站", SiteConfig.SiteOption.CreateHtmlPath, "文件夹写入权限!" });
                    this.ErrorLog(errMsg);
                    return(false);
                }
            }
            return(true);
        }
        public override Stream GetStream(FileSystemObject fso)
        {
            var bki = new S3BucketKeyInfo(fso.FullName);

            var request = new GetObjectRequest
            {
                BucketName = bki.BucketName,
                Key = bki.Key
            };

            try
            {
                return S3Client.GetObject(request).ResponseStream;
            }
            catch (AmazonS3Exception s3x)
            {
                if (IsMissingObjectException(s3x))
                    return null;

                throw;
            }
        }
 public override void Download(FileSystemObject thisFso, FileSystemObject downloadToFso)
 {
     GetToLocalFile(thisFso, downloadToFso);
 }
        private void MoveInS3(FileSystemObject sourceFso, FileSystemObject targetFso)
        {
            if (sourceFso.Equals(targetFso))
            {
                return;
            }

            // Copy, then delete
            CopyInS3(sourceFso, targetFso);
            Delete(sourceFso);
        }
        public override void Store(Stream stream, FileSystemObject fso)
        {
            var bki = new S3BucketKeyInfo(fso);

            var attemptedBucketCreate = false;

            do
            {
                try
                {
                    var request = new PutObjectRequest
                    {
                        BucketName = bki.BucketName,
                        Key = bki.Key,
                        InputStream = stream,
                        StorageClass = S3StorageClass.Standard
                    };

                    S3Client.PutObject(request);

                    break;
                }
                catch (AmazonS3Exception s3x)
                {
                    if (!attemptedBucketCreate && IsMissingObjectException(s3x))
                    {
                        CreateFolder(fso.FolderName);
                        attemptedBucketCreate = true;
                        continue;
                    }

                    throw;
                }

            } while (true);
        }
        public void SameFullNamesEqualEachOther()
        {
            var test = new FileSystemObject("/test-bucket-name/archive/subdir/testfile_hi.zip/");
            var test2 = new FileSystemObject("/test-bucket-name/archive\\subdir/testfile_hi.zip");

            Assert.AreEqual(test, test2);
            Assert.AreEqual(test.ToString(), test2.ToString());
        }
        public override void Move(FileSystemObject sourceFso, FileSystemObject targetFso, IFileStorageProvider targetProvider = null)
        {
            if (TreatAsS3Provider(targetProvider))
            {
                MoveInS3(sourceFso, targetFso);
                return;
            }

            // Moving across providers. With S3 in this case, need to basically download the file
            // to the local file system first, then copy from there to the target provder

            var localFile = new FileSystemObject(Path.Combine(Path.GetTempPath(), targetFso.FileNameAndExtension));

            try
            {
                GetToLocalFile(sourceFso, localFile);

                targetProvider.Store(localFile, targetFso);

                Delete(sourceFso);
            }
            finally
            {
                localFs.Delete(localFile);
            }

        }
 public abstract bool Exists(FileSystemObject fso);
 public abstract void Download(FileSystemObject thisFso, FileSystemObject localFileSystemFso);
 public abstract void Delete(FileSystemObject fso);
 public abstract void Move(FileSystemObject sourceFso, FileSystemObject targetFso, IFileStorageProvider targetProvider = null);
 public abstract void Store(FileSystemObject localFileSystemFso, FileSystemObject targetFso);
 public abstract void Store(Stream stream, FileSystemObject fso);
 public abstract void Store(byte[] bytes, FileSystemObject fso);
 public abstract Stream GetStream(FileSystemObject fso);
        public void ClonedObjectsEqualEachOther()
        {
            var test = new FileSystemObject("/test-bucket-name/archive/subdir/testfile_hi.zip/");
            var test2 = test.Clone();

            Assert.AreEqual(test, test2);
            Assert.AreEqual(test.ToString(), test2.ToString());
        }
        public override bool Exists(FileSystemObject fso)
        {
            var bki = new S3BucketKeyInfo(fso.FullName);

            var s3FileInfo = new S3FileInfo(S3Client, bki.BucketName, bki.Key);

            return s3FileInfo.Exists;
        }
 public abstract byte[] Get(FileSystemObject fso);