예제 #1
0
        public static List <FileBean> GetFileList(string folder)
        {
            List <FileBean> list = new List <FileBean>();

            string[] fileList = Directory.GetFileSystemEntries(folder);
            foreach (string file in fileList)
            {
                FileBean fb = new FileBean();
                if (Directory.Exists(file))
                {
                    fb.Name        = Path.GetFileName(file);
                    fb.Path        = file;
                    fb.Size        = 0L;
                    fb.LastUpdated = new DirectoryInfo(file).LastWriteTime;
                    fb.IsFolder    = true;
                }
                else
                {
                    fb.Name        = Path.GetFileName(file);
                    fb.Path        = file;
                    fb.Size        = new FileInfo(file).Length;
                    fb.LastUpdated = File.GetLastWriteTime(file);
                    fb.IsFolder    = false;
                }
                list.Add(fb);
            }
            return(list);
        }
예제 #2
0
 public static List<FileBean> GetFileList(string folder)
 {
     List<FileBean> list = new List<FileBean>();
     string[] fileList = Directory.GetFileSystemEntries(folder);
     foreach (string file in fileList)
     {
         FileBean fb = new FileBean();
         if (Directory.Exists(file))
         {
             fb.Name = Path.GetFileName(file);
             fb.Path = file;
             fb.Size = 0L;
             fb.LastUpdated = new DirectoryInfo(file).LastWriteTime;
             fb.IsFolder = true;
         }
         else
         {
             fb.Name = Path.GetFileName(file);
             fb.Path = file;
             fb.Size = new FileInfo(file).Length;
             fb.LastUpdated = File.GetLastWriteTime(file);
             fb.IsFolder = false;
         }
         list.Add(fb);
     }
     return list;
 }
예제 #3
0
    private void AddFile(string add1, string add2, FileType type)
    {
        m_bPath = m_bPath.Replace('\\', '/');
        string newPath = m_bPath + add1 + add2;

        //newPath = newPath.Replace()
        if (Directory.Exists(newPath))
        {
            string[] b_bodypart_src = Directory.GetFiles(newPath, "*", SearchOption.AllDirectories);
            for (int i = 0; i < b_bodypart_src.Length; i++)
            {
                string simpleName = System.IO.Path.GetFileName(b_bodypart_src[i]);
                string id         = simpleName.Split('_')[0];

                if (!Regex.IsMatch(id, @"\d{10}"))
                {
                    continue;
                }


                FileBean fb = new FileBean();
                fb.pre         = m_bPath;
                fb.middlePath1 = add1;
                fb.middlePath2 = add2;
                fb.full        = b_bodypart_src[i];
                fb.simple      = fb.full.Replace(m_bPath + add1, "").Replace('\\', '/');
                branchFiles.Add(fb);
            }
        }

        m_trunkPath = m_trunkPath.Replace('\\', '/');
        newPath     = m_trunkPath + add1 + add2;
        if (Directory.Exists(newPath))
        {
            string[] t_bodypart_src = Directory.GetFiles(newPath, "*", SearchOption.AllDirectories);
            for (int i = 0; i < t_bodypart_src.Length; i++)
            {
                string simpleName = System.IO.Path.GetFileName(t_bodypart_src[i]);
                string id         = simpleName.Split('_')[0];

                if (!Regex.IsMatch(id, @"\d{10}"))
                {
                    continue;
                }
                FileBean fb = new FileBean();
                fb.pre         = m_trunkPath;
                fb.middlePath1 = add1;
                fb.middlePath2 = add2;
                fb.full        = t_bodypart_src[i];
                fb.simple      = fb.full.Replace(m_trunkPath + add1, "").Replace('\\', '/');
                trunkFiles.Add(fb);
            }
        }
    }
예제 #4
0
    private void RefreshList()
    {
        string android  = "/android";
        string ios      = "/iOS";
        string bodypart = "/assetbundles/art/role/bodypart";
        string link     = "/assetbundles/art/role/link";
        string icon     = "/assetbundles/texture/item_icon";


        string cdn_pre = "/CDN/SourceFiles";

        AddFile(cdn_pre, android + bodypart, FileType.CDN);
        AddFile(cdn_pre, android + link, FileType.CDN);
        AddFile(cdn_pre, android + icon, FileType.CDN);
        AddFile(cdn_pre, ios + bodypart, FileType.CDN);
        AddFile(cdn_pre, ios + link, FileType.CDN);
        AddFile(cdn_pre, ios + icon, FileType.CDN);

        string inv_pre = "/Inventory/";

        AddFile(inv_pre, android + bodypart, FileType.INV);
        AddFile(inv_pre, android + link, FileType.INV);
        AddFile(inv_pre, android + icon, FileType.INV);
        AddFile(inv_pre, ios + bodypart, FileType.INV);
        AddFile(inv_pre, ios + link, FileType.INV);
        AddFile(inv_pre, ios + icon, FileType.INV);

        string pending = "/PendingResource/";
        string newPath = m_bPath + pending;

        string[] pending_src = Directory.GetFiles(newPath, "*", SearchOption.AllDirectories);
        for (int i = 0; i < pending_src.Length; i++)
        {
            string simpleName = System.IO.Path.GetFileName(pending_src[i]);
            string id         = simpleName.Split('_')[0];

            if (!Regex.IsMatch(id, @"\d{10}"))
            {
                continue;
            }


            FileBean fb = new FileBean();
            fb.pre         = m_bPath;
            fb.middlePath1 = pending;
            fb.full        = pending_src[i];
            fb.simple      = fb.full.Replace(m_bPath + pending, "").Replace('\\', '/');
            pendingFiles.Add(fb);
        }
    }
예제 #5
0
    private bool B2T(FileBean file, List <FileBean> thisList)
    {
        List <FileBean> fbList   = thisList.FindAll(y => file.simple.Equals(y.simple));
        string          copyPath = m_trunkPath + file.middlePath1 + file.simple;

        if (fbList == null || fbList.Count == 0)
        {
            //trunk找不到的,直接拷贝过来.

            string strPath = Path.GetDirectoryName(copyPath);
            if (!Directory.Exists(strPath))
            {
                Directory.CreateDirectory(strPath);
            }
            FileBean pendingFile = pendingFiles.Find(y => y.simple.Equals(file.simple));
            if (pendingFile != null)
            {
                addList.Add(copyPath);
                //System.IO.File.Copy(file.full, copyPath);
            }
            else
            {
                checkList.Add(copyPath);
                System.IO.File.Copy(file.full, copyPath);
            }
        }
        else
        {
            //需要保持一致. 删除trunk中的原有, 把branches里面的东西拷贝过来.
            //这里有个前提:保证branches里面的cdn和inv里面的文件没有重复!!!!!!!!!这个前提很重要!!!
            for (int i = 0; i < fbList.Count; i++)
            {
                //System.IO.File.SetAttributes(fbList[i].full, System.IO.FileAttributes.Normal);
                //System.IO.File.Delete(fbList[i].full);
                deleteList.Add(fbList[i].full);
            }
            string strPath = Path.GetDirectoryName(copyPath);
            if (!Directory.Exists(strPath))
            {
                Directory.CreateDirectory(strPath);
            }
            addList.Add(copyPath);
            //System.IO.File.Copy(file.full, copyPath);
        }
        return(false);
    }
예제 #6
0
        protected List <FileBean> GetFileList(string folder)
        {
            List <FileBean> list = new List <FileBean>();
            DirectoryInfo   di;

            DirectoryInfo[] DirectList;
            try
            {
                di         = new DirectoryInfo(folder);
                DirectList = di.GetDirectories();
            }
            catch (Exception)
            {
                di         = new DirectoryInfo(HttpContext.Current.Server.MapPath(this.lockpath));
                DirectList = di.GetDirectories();
            }

            //获取目录
            DirectList = di.GetDirectories();
            foreach (DirectoryInfo oneFilelist in DirectList)
            {
                FileBean fb = new FileBean();
                fb.Name        = oneFilelist.Name;
                fb.Path        = folder;
                fb.Size        = 0L;
                fb.LastUpdated = oneFilelist.CreationTime;
                fb.IsFolder    = true;
                fb.FlieType    = "folder";
                list.Add(fb);
            }
            //获取文件
            FileInfo[] filelist = di.GetFiles();
            foreach (FileInfo item in filelist)
            {
                FileBean fb = new FileBean();
                fb.Name        = item.Name;
                fb.Path        = item.FullName;
                fb.Size        = item.Length;
                fb.LastUpdated = item.CreationTime;
                fb.IsFolder    = false;
                fb.FlieType    = item.Extension.Remove(0, 1);
                list.Add(fb);
            }
            return(list);
        }
예제 #7
0
파일: Temple.aspx.cs 프로젝트: priceLiu/CMS
    protected List<FileBean> GetFileList(string folder)
    {
        List<FileBean> list = new List<FileBean>();
            DirectoryInfo di;
            DirectoryInfo[] DirectList;
            try
            {
                di = new DirectoryInfo(folder);
                DirectList = di.GetDirectories();
            }
            catch (Exception)
            {

                di = new DirectoryInfo(HttpContext.Current.Server.MapPath(this.lockpath));
                DirectList = di.GetDirectories();
            }

            //获取目录
            DirectList = di.GetDirectories();
            foreach (DirectoryInfo oneFilelist in DirectList)
            {
                FileBean fb = new FileBean();
                fb.Name = oneFilelist.Name;
                fb.Path = folder;
                fb.Size = 0L;
                fb.LastUpdated = oneFilelist.CreationTime;
                fb.IsFolder = true;
                fb.FlieType = "folder";
                list.Add(fb);
            }
            //获取文件
            FileInfo[] filelist = di.GetFiles();
            foreach (FileInfo item in filelist)
            {
                FileBean fb = new FileBean();
                fb.Name = item.Name;
                fb.Path = item.FullName;
                fb.Size = item.Length;
                fb.LastUpdated = item.CreationTime;
                fb.IsFolder = false;
                fb.FlieType = item.Extension.Remove(0, 1);
                list.Add(fb);
            }
            return list;
    }
예제 #8
0
        private int UpdateBoard()
        {
            try
            {
                Board_Tx_Dac  oWS  = new Board_Tx_Dac();
                Board_NTx_Dac oWSN = new Board_NTx_Dac();

                int    ModIdx           = IntegerUtil.intValid(WebUtil.SCRequestFormString("hdfIdx", string.Empty), 0);
                int    intBoardCategory = Convert.ToInt32(WebUtil.SCRequestFormString("ddlBoardCategory", "1"));
                int    intWriteCategory = Convert.ToInt32(WebUtil.SCRequestFormString("ddlWriteCategory", "1"));
                string strUserId        = WebUtil.SCRequestFormString("txtUserId", string.Empty);
                string strWriter        = WebUtil.SCRequestFormString("txtWriter", string.Empty);
                string strSubject       = WebUtil.SCRequestFormString("txtSubject", string.Empty);
                string strContent       = WebUtil.SCRequestFormString("txtContent", string.Empty);

                string ChkBoxListData = string.Empty;

                DataSet   ds              = null;
                DataTable dt              = null; // 삭제할 목록 조회
                DataTable dt1             = null; // 삭제하지 않는 목록 조회
                int       NoDeleteFileCnt = 0;    // 삭제하지 않는 파일 수

                //파일 리스트 조회(삭제할 목록과 삭제 하지 않을 목록 분리하여 가져옴)
                //체크박스 선택 여부
                if (ModIdx > 0 && Request.Form["chkAttached_" + ModIdx + ""] != null)
                {
                    ChkBoxListData = Request.Form["chkAttached_" + ModIdx + ""].ToString();
                    ds             = oWSN.TOTALBBS_BOARD_FILE_INFO_SEL(ModIdx, ChkBoxListData);
                }
                else
                {
                    ChkBoxListData = "0";
                    ds             = oWSN.TOTALBBS_BOARD_FILE_INFO_SEL(ModIdx, ChkBoxListData);
                }

                string OldFileName    = string.Empty;
                string NewFileName    = string.Empty;
                string FileUploadPath = string.Empty;

                if (ds != null)
                {
                    dt  = ds.Tables[0];   // 삭제할 목록 조회
                    dt1 = ds.Tables[1];   // 삭제하지 않는 목록 조회
                    if (dt1.Rows.Count > 0)
                    {
                        NoDeleteFileCnt = dt1.Rows.Count;
                    }
                }

                int             iData           = 0;
                List <FileBean> GecAttachedList = new List <FileBean>();
                if (ds != null)
                {
                    //삭제 하지 않을 목록을 조회 하여 처리
                    foreach (DataRow dr in dt1.Rows)
                    {
                        if (iData == 0)
                        {
                            OldFileName    = dr["strRealFileName"].ToString();
                            NewFileName    = dr["strFileName"].ToString();
                            FileUploadPath = dr["strFilePath"].ToString();
                        }
                        iData = iData + 1;
                        FileBean AFBean = new FileBean();
                        AFBean.strRealFileName = dr["strRealFileName"].ToString();  // 파일 원본 이름
                        AFBean.strFileName     = dr["strFileName"].ToString();      // 파일 업로드후 생성된 새이름
                        AFBean.strFilePath     = dr["strFilePath"].ToString();      // 파일 업로드 경로 디비에 넣지 않는경우 /FileUpload/  + FileUploadPath경로 수동 입력 해도됨
                        AFBean.intFileSort     = iData;
                        GecAttachedList.Add(AFBean);
                    }
                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            for (int i = 0; i < 1; i++)
                            {
                                FileUploadPath = dr["strFilePath"].ToString();
                            }
                        }
                    }
                }

                HttpFileCollection files = HttpContext.Current.Request.Files;

                int FileTotalCnt = files.Count;
                int FileSort     = 0;


                // 웹 취약성 추가 파일 첨부시 aspx 에서 검사 후 cs 단에서 한번 더 검사
                string[] ContentType = null;        // 첨부파일 타입 구분배열 변수

                #region [파일 업로드 정보를 조회]
                if (FileTotalCnt > 0)
                {
                    for (int i = 0; i < FileTotalCnt; i++)
                    {
                        HttpPostedFile postedFile = files[i];
                        FileBean       AFBean     = new FileBean();

                        FileSort = iData + i;
                        string[] FilesInfo1 = new string[3];

                        ContentType = postedFile.ContentType.Split('/');
                        //빈파일일때
                        if (postedFile.ContentLength > 1)
                        {
                            FilesInfo1 = FileName(postedFile);

                            if (FilesInfo1 != null)
                            {
                                if (FileSort == 0)
                                {
                                    OldFileName    = FilesInfo1[0];
                                    NewFileName    = FilesInfo1[1];
                                    FileUploadPath = FilesInfo1[2];
                                }
                                AFBean.strRealFileName = FilesInfo1[0];     // 파일 원본 이름
                                AFBean.strFileName     = FilesInfo1[1];     // 파일 업로드후 생성된 새이름
                                AFBean.strFilePath     = FilesInfo1[2];     // 파일 업로드 경로 디비에 넣지 않는경우 /FileUpload/  + FileUploadPath경로 수동 입력 해도됨
                                AFBean.intFileSort     = FileSort + 1;
                                GecAttachedList.Add(AFBean);
                            }
                            else
                            {
                                FileTotalCnt = 0;
                            }
                        }
                        else
                        {
                            FileTotalCnt = 0;
                        }
                    }
                }
                #endregion

                int MasterReturnValue = 0;
                int ReturnValue       = 0;

                MasterReturnValue = oWS.TOTALBBS_BOARD_INFO_UPD(ModIdx, intBoardCategory, intWriteCategory, strUserId, strWriter, strSubject, strContent);

                if (MasterReturnValue > 0)
                {
                    if (GecAttachedList.Count > 0)
                    {
                        foreach (FileBean Item in GecAttachedList)
                        {
                            ReturnValue = oWS.TOTALBBS_BOARD_FILE_INFO_UPD(ModIdx, Item.strRealFileName, Item.strFileName, Item.strFilePath, Item.intFileSort);
                        }
                    }
                    else
                    {
                        //전체 제크 및 한개만 있을때 체크 했을때
                        ReturnValue = oWS.TOTALBBS_BOARD_FILE_INFO_DEL_SELECTED(ChkBoxListData);
                    }
                }

                //첨부파일 등록이 하나도 없을시
                if (GecAttachedList.Count.Equals(0))
                {
                    ReturnValue = -10;
                }
                //체크박스 선택 파일 삭제 시키기
                if (!ChkBoxListData.Equals("0"))
                {
                    //삭제
                    foreach (DataRow dr in dt.Rows)
                    {
                        //경로를 넘기는데 \\ 수가 맞지 않아 메서드 추가함 수정시 삭제에 사용
                        LocalFileControls.FileDelete_New(FileUploadPath, dr["strFileName"].ToString());
                    }
                }
                return(ReturnValue);
            }
            catch (Exception ex)
            {
                #region [Error Logger] 로그인을 한경우
                //ErrorLogger_Tx_Dac.GetErrorLogger_Tx_Dac().TB_TOTABBS_ERROR_LOGGER_INFO_INS_SP(ex, admin.MemberId, admin.MemberNm);
                #endregion

                return(0);
            }
        }