Exemple #1
0
        protected void repFileReName_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            string pdir  = function.VToP(CurDirPath);
            string ppath = pdir + e.CommandArgument.ToString();
            string fname = Path.GetFileNameWithoutExtension(e.CommandArgument.ToString());
            string ext   = Path.GetExtension(e.CommandArgument.ToString());

            if (e.CommandName == "DelFiles")
            {
                FileSystemObject.Delete(ppath, FsoMethod.File);
                Response.Redirect(Request.RawUrl);
            }
            if (e.CommandName == "DelDir")
            {
                FileSystemObject.Delete(ppath, FsoMethod.Folder);
                Response.Redirect(Request.RawUrl);
            }
            if (e.CommandName == "CopyDir")
            {
                FileSystemObject.CopyDirectory(ppath, pdir + fname + "_" + Resources.L.制 + ext); //"复制_" + ppath
                Response.Redirect(Request.RawUrl);
            }
            if (e.CommandName == "CopyFiles")
            {
                FileSystemObject.CopyFile(ppath, pdir + fname + "_" + Resources.L.制 + ext);
                Response.Redirect(Request.RawUrl);
            }
            if (e.CommandName == "DownFiles")
            {
                SafeSC.DownFile(CurDirPath + e.CommandArgument.ToString(), e.CommandArgument.ToString());
            }
        }
        protected void repFileReName_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            string fname = Path.GetFileNameWithoutExtension(e.CommandArgument.ToString());
            string ext   = Path.GetExtension(e.CommandArgument.ToString());

            if (e.CommandName == "DelFiles")
            {
                FileSystemObject.Delete(PPathDir + e.CommandArgument.ToString(), FsoMethod.File);
            }
            if (e.CommandName == "DelDir")
            {
                FileSystemObject.Delete(PPathDir + e.CommandArgument.ToString(), FsoMethod.Folder);
            }
            if (e.CommandName == "CopyFiles")
            {
                FileSystemObject.CopyFile(PPathDir + e.CommandArgument.ToString(), PPathDir + fname + "_复制" + ext);
            }
            if (e.CommandName == "CopyDir")
            {
                FileSystemObject.CopyDirectory(PPathDir + e.CommandArgument.ToString(), PPathDir + fname + "_复制" + ext);
            }
            if (e.CommandName == "DownFiles")
            {
                string filePath = function.PToV(PPathDir) + e.CommandArgument.ToString();

                SafeSC.DownFile(filePath, HttpUtility.UrlEncode(e.CommandArgument.ToString(), System.Text.Encoding.UTF8));
            }
            Response.Redirect(Request.RawUrl);
        }
        protected void EgvFiles_RowCommand(object sender, CommandEventArgs e)
        {
            try
            {
                string str;
                string commandName = e.CommandName;
                if (commandName != null)
                {
                    if (!(commandName == "DelFiles"))
                    {
                        if (commandName == "DelDir")
                        {
                            goto Label_0082;
                        }
                        if (commandName == "CopyDir")
                        {
                            goto Label_00C3;
                        }
                        if (commandName == "CopyFiles")
                        {
                            goto Label_01A7;
                        }
                    }
                    else
                    {
                        FileSystemObject.Delete(this.currentDirectory + e.CommandArgument.ToString(), FsoMethod.File);
                        AdminPage.WriteSuccessMsg("<li>删除文件成功。</li>", this.m_UrlReferrer);
                    }
                }
                return;

Label_0082:
                base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
                FileSystemObject.Delete(this.currentDirectory + e.CommandArgument.ToString(), FsoMethod.Folder);
                AdminPage.WriteSuccessMsg("<li>删除目录成功。</li>", this.m_UrlReferrer);
                return;

Label_00C3:
                if (!FileSystemObject.IsExist(this.currentDirectory + "复件" + e.CommandArgument.ToString(), FsoMethod.Folder))
                {
                    base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
                    FileSystemObject.CopyDirectory(this.currentDirectory + e.CommandArgument.ToString(), this.currentDirectory + "复件" + e.CommandArgument.ToString());
                    AdminPage.WriteSuccessMsg("<li>复制目录成功。</li>", this.m_UrlReferrer);
                }
                else
                {
                    this.HdnCopyDir.Value = e.CommandArgument.ToString();
                    this.LblCopyDir.Text  = "复件" + e.CommandArgument.ToString();
                    this.TxtCopyDir.Text  = "复件" + e.CommandArgument.ToString();
                    this.MpeCopyDir.Show();
                }
                return;

Label_01A7:
                str = e.CommandArgument.ToString();
                if (!string.IsNullOrEmpty(str))
                {
                    string[] strArray = str.Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
                    string   newValue = "复件" + strArray[strArray.Length - 1];
                    string   str3     = str.Replace(strArray[strArray.Length - 1], newValue);
                    if (!FileSystemObject.IsExist(this.currentDirectory + str3, FsoMethod.File))
                    {
                        FileSystemObject.CopyFile(this.currentDirectory + e.CommandArgument.ToString(), this.currentDirectory + str3);
                        AdminPage.WriteSuccessMsg("<li>复制文件成功。</li>", this.m_UrlReferrer);
                    }
                    else
                    {
                        this.HdnCopyFile.Value = e.CommandArgument.ToString();
                        this.LblCopyFile.Text  = str3;
                        this.TxtCopyFile.Text  = str3;
                        this.MpeCopyFile.Show();
                    }
                }
            }
            catch (FileNotFoundException)
            {
                AdminPage.WriteErrMsg("<li>文件未找到!</li>", this.m_UrlReferrer);
            }
            catch (UnauthorizedAccessException)
            {
                AdminPage.WriteErrMsg("<li>访问文件夹或文件时失败!检查您的服务器是否给模板文件夹写入权限。</li>", this.m_UrlReferrer);
            }
        }
 protected void EBtnCopyFile_Click(object sender, EventArgs e)
 {
     base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
     FileSystemObject.CopyFile(this.currentDirectory + this.HdnCopyFile.Value, this.currentDirectory + this.TxtCopyFile.Text);
     AdminPage.WriteSuccessMsg("<li>复制文件成功。</li>", this.m_UrlReferrer);
 }