Ejemplo n.º 1
0
            /// <summary>
            ///     Downloads the modded files archive and extracts all files to <see cref="DownloadDataDirectory"/>
            /// </summary>
            public void DownloadInstallFiles()
            {
                string archivePath     = DownloadDataDirectory;
                string archiveFilePath = ArchiveZipFile;

                if (!MainWindow.Settings.AlwaysDownloadInstallFiles && File.Exists(archiveFilePath))
                {
                    return;
                }

                if (Directory.Exists(archivePath))
                {
                    UserFolders.DeleteDirectory(archivePath);
                }

                if (!Directory.Exists(archivePath))
                {
                    _ = Directory.CreateDirectory(archivePath);
                }

                if (File.Exists(archiveFilePath))
                {
                    File.Delete(archiveFilePath);
                }

                _ = Directory.CreateDirectory(archivePath);

                using (WebClient wc = new WebClient())
                {
                    wc.Headers.Add("Accept: application/zip");
                    wc.Headers.Add("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
                    wc.DownloadFile(new Uri(Url), archiveFilePath);
                    ZipFile.ExtractToDirectory(archiveFilePath, archivePath);
                }
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Downloads the modded files archive and extracts all files to <see cref="DownloadDataDirectory"/>
        /// </summary>
        /// <param name="downloadFiles"></param>
        public void DownloadInstallFiles(DownloadFiles downloadFiles)
        {
            string archivePath     = DownloadDataDirectory(downloadFiles);
            string archiveFilePath = ArchiveZipFile(downloadFiles);

            if (Directory.Exists(archivePath))
            {
                UserFolders.DeleteDirectory(archivePath);
            }

            if (!Directory.Exists(archivePath))
            {
                Directory.CreateDirectory(archivePath);
            }

            if (File.Exists(archiveFilePath))
            {
                File.Delete(archiveFilePath);
            }

            Directory.CreateDirectory(archivePath);

            using (WebClient webClient = new WebClient())
            {
                webClient.Headers.Add("Accept: application/zip");
                webClient.Headers.Add("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
                webClient.DownloadFile(new Uri(downloadFiles.URL), archiveFilePath);
            }

            ZipFile.ExtractToDirectory(archiveFilePath, archivePath);
        }
Ejemplo n.º 3
0
        public virtual FolderInfo GetUserFolder(string path)
        {
            string dbPath = (string)(string)FileSystemValidation.ToDBPath(path);

            if (UserFolders.ContainsKey(dbPath))
            {
                return(UserFolders[dbPath]);
            }

            return(null);
        }
Ejemplo n.º 4
0
        protected List <MailUserFolderData> GetUserFolders()
        {
            if (UserFolders == null)
            {
                UserFolders = new List <MailUserFolderData>();
            }

            if (UserFolders.Any())
            {
                return(UserFolders);
            }

            UserFolders = EngineFactory.UserFolderEngine.GetList();

            return(UserFolders);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取用户的各种路径
        /// </summary>
        /// <returns></returns>
        public static UserFolders GetUserFolders()
        {
            UserFolders pRet = new UserFolders();

            //string sSubKey  = "software\\Microsoft";
            //string sUserFolderPath = "windows/currentversion/explorer/shell folders";

            //pRet.DesktopPath    = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Common Desktop",    sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.FontsPath      = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Fonts",             sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.NethoodPath    = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Nethood",           sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.PersonalPath   = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Personal",          sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.ProgramsPath   = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Programs",          sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.RecentPath     = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Recent",            sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.SendToPath     = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Sendto",            sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.StartMenuPath  = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Startmenu",         sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.StartUpPath    = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Startup",           sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.FavoritesPath  = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Favorites",         sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.HistoryPath    = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "History",           sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.CookiesPath    = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Cookies",           sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.CachePath      = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Cache",             sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.AppdataPath    = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Appdata",           sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            //pRet.PrinthoodPath  = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Printhood",         sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);

            pRet.DesktopPath   = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            pRet.FontsPath     = Environment.GetFolderPath(Environment.SpecialFolder.Fonts);
            pRet.NethoodPath   = Environment.GetFolderPath(Environment.SpecialFolder.NetworkShortcuts);
            pRet.PersonalPath  = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            pRet.ProgramsPath  = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            pRet.RecentPath    = Environment.GetFolderPath(Environment.SpecialFolder.Recent);
            pRet.SendToPath    = Environment.GetFolderPath(Environment.SpecialFolder.SendTo);
            pRet.StartMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
            pRet.StartUpPath   = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
            pRet.FavoritesPath = Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
            pRet.HistoryPath   = Environment.GetFolderPath(Environment.SpecialFolder.History);
            pRet.CookiesPath   = Environment.GetFolderPath(Environment.SpecialFolder.Cookies);
            pRet.CachePath     = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
            pRet.AppdataPath   = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            pRet.PrinthoodPath = Environment.GetFolderPath(Environment.SpecialFolder.PrinterShortcuts);
            return(pRet);
        }
Ejemplo n.º 6
0
        public void DeleteLocalItem()
        {
            try
            {
                if (XtraMessageBox.Show("Do you really want to delete the selected item?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    string type = GridViewLocalFiles.GetRowCellValue(GridViewLocalFiles.FocusedRowHandle, "Type").ToString();
                    string name = GridViewLocalFiles.GetRowCellValue(GridViewLocalFiles.FocusedRowHandle, "Name").ToString();

                    if (!name.Equals(".."))
                    {
                        string selectedItem = TextBoxLocalPath.Text + @"\" + name;

                        if (type.Equals("folder"))
                        {
                            SetLocalStatus($"Deleting folder: {selectedItem}");
                            UserFolders.DeleteDirectory(selectedItem);
                            SetLocalStatus($"Successfully deleted folder: {name}");
                        }
                        else if (type.Equals("file"))
                        {
                            if (File.Exists(selectedItem))
                            {
                                SetLocalStatus($"Deleting file: {selectedItem}");
                                File.Delete(selectedItem);
                                SetLocalStatus($"Successfully deleted file: {name}");
                            }
                        }
                    }

                    GridViewLocalFiles.DeleteRow(GridViewLocalFiles.FocusedRowHandle);
                }
            }
            catch (Exception ex)
            {
                SetLocalStatus($"Unable to delete item. Error: {ex.Message}", ex);
            }
        }
Ejemplo n.º 7
0
        public void DeleteLocalItem()
        {
            try
            {
                if (DarkMessageBox.Show(this, "Do you really want to delete the selected item?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    var type = DgvLocalFiles.CurrentRow.Cells[0].Value.ToString();
                    var name = DgvLocalFiles.CurrentRow.Cells[2].Value.ToString();

                    if (!name.Equals(".."))
                    {
                        var selectedItem = TextBoxLocalPath.Text + @"\" + DgvLocalFiles.CurrentRow.Cells[2].Value;

                        if (type.Equals("folder"))
                        {
                            SetLocalStatus($"Deleting folder: {selectedItem}");
                            UserFolders.DeleteDirectory(selectedItem);
                            SetLocalStatus($"Successfully deleted folder: {name}");
                        }
                        else if (type.Equals("file"))
                        {
                            if (File.Exists(selectedItem))
                            {
                                SetLocalStatus($"Deleting file: {selectedItem}");
                                File.Delete(selectedItem);
                                SetLocalStatus($"Successfully deleted file: {name}");
                            }
                        }
                    }

                    DgvLocalFiles.Rows.RemoveAt(DgvLocalFiles.CurrentRow.Index);
                }
            }
            catch (Exception ex)
            {
                SetLocalStatus($"Unable to delete item. Error: {ex.Message}", ex);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取用户的各种路径
        /// </summary>
        /// <returns></returns>
        public static UserFolders GetUserFolders()
        {
            UserFolders pRet = new UserFolders();

            string sSubKey         = "software\\Microsoft";
            string sUserFolderPath = "windows/currentversion/explorer/shell folders";

            pRet.DesktopPath   = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Common Desktop", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.FontsPath     = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Fonts", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.NethoodPath   = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Nethood", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.PersonalPath  = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Personal", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.ProgramsPath  = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Programs", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.RecentPath    = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Recent", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.SendToPath    = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Sendto", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.StartMenuPath = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Startmenu", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.StartUpPath   = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Startup", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.FavoritesPath = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Favorites", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.HistoryPath   = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "History", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.CookiesPath   = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Cookies", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.CachePath     = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Cache", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.AppdataPath   = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Appdata", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            pRet.PrinthoodPath = AIGS.Helper.RegistryHelper.GetValue(sUserFolderPath, "Printhood", sSubKey, AIGS.Helper.RegistryHelper.ROOT.LOCAL_MACHINE);
            return(pRet);
        }
Ejemplo n.º 9
0
 public virtual bool CanViewFolder(FolderInfo dnnFolder)
 {
     return(UserFolders.ContainsKey(dnnFolder.FolderPath));
 }
Ejemplo n.º 10
0
 public virtual bool CanViewFolder(string path)
 {
     return(UserFolders.ContainsKey(ToDBPath(path)));
 }