Example #1
0
        private static async void _set()
        {
            isLoading = true;

            items    = new ObservableCollection <HistoryItem>();
            newItems = new List <HistoryItem>();

            IsEnabled       = AppSettings.Get("App", "SaveHistory", true);
            FileAppPath     = DirectoryHelper.CurrentDirectory + fileName;
            FileRoamingPath = AppSettings.RoamingPath + fileName;
            FilePath        = FileRoamingPath;

            timer          = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(1000);
            timer.Tick    += new EventHandler(timer_Tick);

            if (FileHelper.Exists(FileAppPath))
            {
                FilePath = FileAppPath;
            }

            await load();

            isLoading = false;
        }
Example #2
0
        private static void _set()
        {
            FileRoamingPath = AppSettings.RoamingPath + fileName;
            FileAppPath     = DirectoryHelper.CurrentDirectory + fileName;
            FilePath        = FileRoamingPath;
            isLoaded        = false;

            if (FileHelper.Exists(FileAppPath))
            {
                FilePath = FileAppPath;
            }
        }
Example #3
0
        private static void _set()
        {
            settings        = new Dictionary <string, Setting>(10);
            RoamingPath     = DirectoryHelper.ApplicationData + @"\PlusFTP";
            FileRoamingPath = RoamingPath + fileName;
            FileAppPath     = DirectoryHelper.CurrentDirectory + fileName;
            FilePath        = FileRoamingPath;

            if (FileHelper.Exists(FileAppPath))
            {
                SameAppPath = true; FilePath = FileAppPath; loadConf(FileAppPath);
            }
            else if (FileHelper.Exists(FileRoamingPath))
            {
                loadConf(FileRoamingPath);
            }
            else
            {
                DirectoryHelper.Create(RoamingPath);
            }
        }
Example #4
0
        private static bool hasTmpFile()
        {
            string tmpFile = DirectoryHelper.Temp + DragWatcher.Source;

            if (FileHelper.Exists(tmpFile))
            {
                return(true);
            }
            else
            {
                using (FileStream fs = FileHelper.Create(tmpFile))
                {
                    if (fs != null)
                    {
                        File.SetAttributes(tmpFile, FileAttributes.Hidden | FileAttributes.System);
                        return(true);
                    }
                }
            }

            return(false);
        }
        protected async Task <SmartItem[]> _prepareForUpload(string[] items, string destination)
        {
            List <SmartItem> uploadList = new List <SmartItem>();
            IList <string>   folders    = new List <string>();

            await Task.Run(async delegate
            {
                for (int i = 0; i < items.Length; i++)
                {
                    if (Paused)
                    {
                        while (Paused && !IsCanceled)
                        {
                            await Task.Delay(200);
                        }
                    }
                    if (IsCanceled)
                    {
                        break;
                    }
                    if (FileHelper.Exists(items[i]))
                    {
                        FileInfo file = null;
                        try
                        {
                            file = new FileInfo(items[i]);
                            uploadList.Add(new SmartItem(file, destination));
                            TransferEvent.TotalSize += file.Length;
                            TransferEvent.TotalFiles++;
                        }
                        catch (Exception exp) { ExceptionHelper.Log(exp); }
                        file = null;
                    }
                    else if (DirectoryHelper.Exists(items[i]))
                    {
                        folders.Add(items[i]);
                    }
                }
                items = null;

                for (int i = 0; i < folders.Count; i++)
                {
                    if (Paused)
                    {
                        while (Paused && !IsCanceled)
                        {
                            await Task.Delay(200);
                        }
                    }
                    if (IsCanceled)
                    {
                        break;
                    }
                    uploadList.AddRange(await _getLocalItems(new DirectoryInfo(folders[i]), destination, -1, uploadList.Count));
                }
                folders = null;
            });

            if (IsCanceled)
            {
                return new SmartItem[] { }
            }
            ;
            return(uploadList.ToArray());
        }