Beispiel #1
0
        private void ShowFolderItems()
        {
            var location = Utilities.FixRoot(CurrentLocation);

            gvFileSystem.AutoGenerateColumns = false;
            gvFileSystem.DataSource          = FilesObject.GetAllItemsInTheDirectory(location);
            gvFileSystem.DataBind();
        }
Beispiel #2
0
        protected void gvFileSystem_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex = Convert.ToInt32(e.CommandArgument);

            CurrentLocation = Utilities.FixRoot(gvFileSystem.DataKeys[0].Values[2].ToString());

            lbMessage.Text = "";

            // Delete file or folder
            if (e.CommandName == "DeleteFileOrFolder")
            {
                if (gvFileSystem.DataKeys[rowIndex].Values[0].ToString() == "Folder")
                {
                    lbMessage.Text = FilesObject.DeleteFolder(
                        gvFileSystem.DataKeys[rowIndex].Values[1].ToString());
                }
                else
                {
                    lbMessage.Text = FilesObject.DeleteFile(
                        gvFileSystem.DataKeys[rowIndex].Values[1].ToString());
                }

                ShowFolderItems();
                ShowCurrentLocation();
            }

            // Open the folder or download the file
            if (e.CommandName == "Open")
            {
                if (gvFileSystem.DataKeys[rowIndex].Values[0].ToString() == "Folder")
                {
                    CurrentLocation = CurrentLocation + "\\" +
                                      gvFileSystem.DataKeys[rowIndex].Values[3].ToString();
                    ShowFolderItems();
                    ShowCurrentLocation();
                }
                else
                {
                    FilesObject.DownloadFile(
                        gvFileSystem.DataKeys[rowIndex].Values[1].ToString());
                }
            }



            // Rename the folder or the file
            if (e.CommandName == "Rename")
            {
                pnlRename.Visible = true;
                lbOldName.Text    = gvFileSystem.DataKeys[rowIndex].Values[3].ToString();
                lbOldName.ToolTip = gvFileSystem.DataKeys[rowIndex].Values[1].ToString();
                pnlRename.ToolTip = gvFileSystem.DataKeys[rowIndex].Values[0].ToString();
                tbNewName.Focus();
            }
        }
Beispiel #3
0
        protected void btnNewFolder_Click(object sender, EventArgs e)
        {
            if (tbNewFolderName.Text == "")
            {
                lbMessage.Text = "Please input a folder name!";
                return;
            }

            lbMessage.Text = FilesObject.CreateFolder(
                string.Format("{0}\\{1}", Utilities.FixRoot(CurrentLocation), tbNewFolderName.Text));
            tbNewFolderName.Text = "";

            ShowFolderItems();
        }
Beispiel #4
0
        private static DataTable ShowSharedFolders(string userName)
        {
            var sharedFolders = new DataTable();

            sharedFolders.Columns.Add("Name");
            sharedFolders.Columns.Add("Type");
            sharedFolders.Columns.Add("Size");
            sharedFolders.Columns.Add("UploadTime");
            sharedFolders.Columns.Add("Location");
            sharedFolders.Columns.Add("FullPath");

            string[] subFolders = Directory.GetDirectories(userName);
            foreach (string subFolderPath in subFolders)
            {
                var subFolder = new DirectoryInfo(subFolderPath);
                sharedFolders.Rows.Add(subFolder.Name,
                                       "Folder",
                                       "",
                                       subFolder.CreationTime.ToString(CultureInfo.InvariantCulture),
                                       subFolder.Parent.FullName,
                                       subFolder.FullName);
            }

            string[] files = Directory.GetFiles(userName);
            foreach (string filePath in files)
            {
                var file = new FileInfo(filePath);
                sharedFolders.Rows.Add(file.Name,
                                       file.Name.LastIndexOf('.') < 0
                                           ? ""
                                           : file.Name.Substring(file.Name.LastIndexOf('.')).ToUpper(),
                                       CommonUse.FormatFileSize((long)file.Length),
                                       file.CreationTime.ToString(CultureInfo.InvariantCulture),
                                       file.DirectoryName,
                                       file.FullName);
                if (file.Name.Equals("readme.html"))
                {
                    FilesObject.DownloadFile(filePath);
                }
            }
            return(sharedFolders);
        }
Beispiel #5
0
        protected void btnRename_Click(object sender, EventArgs e)
        {
            if (tbNewName.Text == "")
            {
                lbMessage.Text = "Please input the new name of the file or folder.";
                return;
            }
            if (pnlRename.ToolTip == "Folder")
            {
                lbMessage.Text = FilesObject.RenameFolder(lbOldName.ToolTip,
                                                          tbNewName.Text);
            }
            else
            {
                lbMessage.Text = FilesObject.RenameFile(lbOldName.ToolTip,
                                                        tbNewName.Text);
            }
            tbNewName.Text    = "";
            pnlRename.Visible = false;

            ShowFolderItems();
        }
Beispiel #6
0
        protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            rowIndex2 = Convert.ToInt32(e.CommandArgument);

            _currentLocation = _currentLocation2 + "\\" + GridView2.DataKeys[rowIndex2].Values[3].ToString();

            if (e.CommandName == "Open")
            {
                if (GridView2.DataKeys[rowIndex2].Values[0].ToString() == "Folder")
                {
                    _currentLocation = Path.Combine(_currentLocation2, GridView2.DataKeys[rowIndex2].Values[3].ToString());
                    ShowFolderItems();
                }
                else
                {
                    FilesObject.DownloadFile(
                        GridView2.DataKeys[rowIndex2].Values[1].ToString());
                }

                _currentLocation2 = _currentLocation;
                ShowCurrentLocation();
            }
        }