Exemplo n.º 1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            lblError.Visible = false;

            byte[] fileData;
            CFile file = new FileSystem(Globals.CurrentIdentity).GetFile(Convert.ToInt32(Request.Params["FileID"]));
            string filename= file.Name;

            if (file.IsDirectory()) {
                fileData = GetDirectoryData(file);
                filename += ".zip";
            }
            else {
                try {
                    new FileSystem(Globals.CurrentIdentity).LoadFileData(file);
                } catch (CustomException er) {
                    PageError(er.Message);
                    return;
                }
                fileData = file.RawData;
            }

            Response.Clear();
            Response.ContentType = "application/octet-stream; name=" + filename;
            Response.AddHeader("Content-Disposition","attachment; filename=" + filename);
            Response.AddHeader("Content-Length", fileData.Length.ToString());
            Response.Flush();

            Response.OutputStream.Write(fileData, 0, fileData.Length);
            Response.Flush();
        }
Exemplo n.º 2
0
 private void FileCommand(object source, DataGridCommandEventArgs e)
 {
     CFile file = new FileSystem(Globals.CurrentIdentity).GetFile(
         (int)dgFiles.DataKeys[e.Item.ItemIndex]);
     if (file.IsDirectory()) {
         TreeNode curnode = tvFiles.GetNodeFromIndex(tvFiles.SelectedNodeIndex);
         foreach (TreeNode node in curnode.Nodes) {
             if (node.NodeData == file.FullPath) {
                 ExpandTreeNode(node);
                 ViewState["gridpath"] = node.NodeData;
                 try {
                     tvFiles.SelectedNodeIndex = node.GetNodeIndex();
                 } catch (Exception) {
                     ExpandTreeNode((TreeNode)node.Parent);
                     tvFiles.SelectedNodeIndex = node.GetNodeIndex();
                 }
                 BindFileGrid();
                 break;
             }
         }
     }
 }