Exemplo n.º 1
0
        public SettingView()
        {
            InitializeComponent();

            addonController          = new AddonsControllerFactory().CreateAddonController();
            settingsManager          = domainFactory.CreateSettingsManager();
            FolderClass              = new FolderClass();
            TbFolderPath.DataContext = FolderClass;
        }
Exemplo n.º 2
0
        /// <summary>資料夾路徑讀取(可疊加)</summary>
        /// <param name="tempPath">路徑字串</param>
        /// <param name="MatchUid">對應資料</param>
        /// <returns>Folders[a][b] (格式string[])</returns>
        /// 可用以下方式疊加
        /// rlt.Folders = new List<object>();
        /// rlt.Folders.Add(此函數);
        public static FolderClass[] FolderLoad(string tempPath, string MatchUid)
        {
            //轉換路徑 (需判斷是絕對路徑還是相對路徑)
            string strPath  = "";
            string viewPath = "";

            if (System.IO.Path.IsPathRooted(ConfigurationManager.AppSettings["FilesPath"]) == true)
            {
                //絕對路徑
                strPath = ConfigurationManager.AppSettings["FilesPath"] + tempPath.Replace("/", @"\");
            }
            else
            {
                //相對路徑
                strPath = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["FilesPath"] + tempPath);
            }
            //輸出閱覽路徑
            viewPath = ConfigurationManager.AppSettings["FilesViewPath"] + tempPath;


            List <FolderClass> dataList = new List <FolderClass>();


            //判斷檔案資料夾是否存在
            if (Directory.Exists(strPath))
            {
                //目錄(含路徑)的陣列
                string[] dirs = Directory.GetDirectories(strPath);
                //用來儲存只有目錄名的集合
                ArrayList dirlist = new System.Collections.ArrayList();
                foreach (string item in dirs)
                {
                    //走訪每個元素只取得目錄名稱(不含路徑)並加入dirlist集合中
                    dirlist.Add(Path.GetFileNameWithoutExtension(item));
                }
                //填入資訊
                foreach (var item in dirlist)
                {
                    DirectoryInfo theFolderInfo = new DirectoryInfo(strPath + item.ToString());

                    FolderClass data = new FolderClass();

                    data.MatchUid            = MatchUid;                                //對應資料
                    data.FolderPath          = viewPath;                                //瀏覽路徑
                    data.FolderName          = item.ToString();                         //資料夾名稱
                    data.FolderLastWriteTime = theFolderInfo.LastWriteTime.ToString();  //最後一次存取的時間

                    dataList.Add(data);
                }
            }

            return(dataList.ToArray());
        }