Пример #1
0
        public List <FileProperties> GetAllFiles(string FolderPath)
        {
            var items = new List <FileProperties>();

            try
            {
                foreach (string dir in Directory.GetFiles(FolderPath))
                {
                    FileInfo       _dirinfo = new FileInfo(dir);
                    FileProperties file     = new FileProperties()
                    {
                        CheckboxName = _dirinfo.FullName,
                        FileName     = _dirinfo.Name,
                        CreatedTime  = _dirinfo.CreationTime,
                        Size         = System.String.Format("{0}KB", _dirinfo.Length / 1024),
                    };
                    items.Add(file);
                    file.GetFileName(_dirinfo.FullName);
                }
                return(items);
            }
            catch (System.UnauthorizedAccessException)
            {
                return(null);
            }
        }
Пример #2
0
 private static void SetButtonsClickEvents(Button save, Button cancel, Views.DialogWindow dialogWindow, TextBox fileName, TextBox extension, CheckBox hidden, string path)
 {
     cancel.Click += delegate
     {
         dialogWindow.Close();
     };
     save.Click += delegate
     {
         FileInfo     fileInfo     = new FileInfo(path);
         FileSecurity fileSecurity = fileInfo.GetAccessControl();
         string       user         = System.Environment.UserName;
         fileSecurity.AddAccessRule(new FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow));
         fileInfo.SetAccessControl(fileSecurity);
         FileProperties file = new FileProperties()
         {
             CheckboxName = fileInfo.FullName,
             FileName     = fileInfo.Name,
             CreatedTime  = fileInfo.CreationTime,
             Size         = System.String.Format("{0}KB", fileInfo.Length / 1024),
         };
         file.GetFileName(path);
         file.SetExtension(extension.Text, path);
         if (hidden.IsChecked == true)
         {
             file.isHidden = true;
         }
         else
         {
             file.isHidden = false;
         }
         file.HideFile(path);
         file.ChangeName(fileName.Text, path);
         dialogWindow.Close();
     };
 }
Пример #3
0
        /***************************
        * My Files populate data
        ***************************/
        private void PopulateMyFiles(object sender, MouseButtonEventArgs e)
        {
            VersionCol.Visibility          = Visibility.Visible;
            InMyFiles                      = true;
            SidebarReviseButton.Visibility = Visibility.Visible;
            DatabaseCon con = new DatabaseCon();

            con.OpenConnection();
            List <string> paths = FileData.GetMyFilePath();

            DataGridController data = new DataGridController();
            ObservableCollection <FileAndDirAttributes> GridData = new ObservableCollection <FileAndDirAttributes>();
            FileProperties file;

            if (paths.Count > 0)
            {
                foreach (string dir in paths)
                {
                    file = new FileProperties(dir);
                    GridData.Add(new FileAndDirAttributes {
                        Type = false, FileIcon = "/Resources/Icons/file.png", FileName = file.GetFileName(), FileSize = file.GetFileSize(), FileDirectory = file.GetDirectory(), FileCreated = file.GetFileCreated(), FileAccessed = file.GetFileLastAccess(), FileModified = file.GetFileLastModify(), Versions = FileData.VersionCount(dir)
                    });
                }

                DirsAndFiles.ItemsSource = GridData;
                items.Content            = (GridData.Count - 1) + " items";
                size.Content             = "No file selected.";
            }
            else
            {
                MessageBox.Show("Error", "No file found!");
            }
        }