Join Dotnetcodes DotnetCodes.com is online Discussion Forum for Software professionals . It lets you find friends around the world and Create professional network that share similar interests as you. Get help on ur projects by industry specialists. Also get answers to all ur technical/placement related querries.Get an edge over others.
Already MemberClick here to login
ASP.net MVC Interview Questions Answers Interview Questions
Serial Number in SSRS Articles
How to Print a Crystal Report direct to printer Articles
Get Started Developing for Android Apps with Eclipse Articles
Razor View Engine Interview Questions Answers Interview Questions
.Net framework 4.0 Interview Questions Answers Interview Questions
SQL server reporting services Interview Questions (SSRS) part 1 Articles
Whats New in ASP.NET 4.0 Part 2 Articles
Difference between Encapsulation and Abstraction Interview Questions
Explaining SDLC -System Development Life Cycle Articles
SPIRE PDF Library Articles
Infosys Interview Questions Interview Questions
Html5 interview questions and answers Interview Questions
Dynamic Menu using HTML List Tag and CSS in ASP.Net Articles
SharePoint 2010 interview Questions Answers Interview Questions
Submit Articles | More Articles..

Please Please help......... tooo urgent

Posted By: Jaishree on 11/28/2011 11:25:51 PM | Comments:1 [Forward This]
Hi, I want to select a directory and upload all the files in that to the server using asp.net..... is there anyway to do that...... if anyone knows please tell me the code... its too urgent... i have to submit it on this week...Pleaseeeeeeee

Dear Friends, Dont forget to bookmark and submit your posting to social websites listed above.It will bring more visibility, buzz and fast action to attend your post

Responses to the Discussion: Please Please help......... tooo urgent
Reply by: rakesh on: 11/29/2011 3:51:39 AM
Use Follow Code: The Controls are Treeview,Gridview using System; using System.IO; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } private void FillDirectory(TreeNode parent, string strPath) { DirectoryInfo dr = new DirectoryInfo(strPath); if (dr.Exists) { foreach (DirectoryInfo d in dr.GetDirectories()) { TreeNode node = new TreeNode(); node.Text = d.Name; node.Value = d.FullName; node.PopulateOnDemand = true; node.SelectAction = TreeNodeSelectAction.SelectExpand; parent.ChildNodes.Add(node); } } } protected void DirTreeview_TreeNodePopulate(object sender, TreeNodeEventArgs e) { string selectedstring = e.Node.Value; string strFileName = Path.Combine(currentFolderPath, selectedstring); FillDirectory(e.Node, strFileName); //BindDirContents(e.Node, gridviewFiles); } public String currentFolderPath { get { if (ViewState["m_currentFolderPath"] != null) return ViewState["m_currentFolderPath"].ToString().Trim(); else return string.Empty; } set { ViewState["m_currentFolderPath"] = value; } } private static void BindDirContents(TreeNode node, System.Web.UI.WebControls.GridView gridview) { // bind the gridview to the datasource gridview.DataSource = new System.IO.DirectoryInfo(node.Value).GetFiles(); gridview.DataBind(); } protected void gridviewFiles_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { System.IO.FileSystemInfo item = (System.IO.FileSystemInfo)e.Row.DataItem; ImageButton imageButton = (ImageButton)e.Row.FindControl("btnItemIcon"); System.IO.FileInfo fileInfo = (System.IO.FileInfo)item; Label lblSize = (Label)e.Row.FindControl("lblSize"); lblSize.Text = string.Format("{0:N0} KB", fileInfo.Length / 1000); if ((fileInfo.Name.EndsWith(".rtf") || fileInfo.Name.EndsWith(".doc") || fileInfo.Name.EndsWith(".txt"))) { imageButton.ImageUrl = @"Image/doc.jpg"; } else { imageButton.ImageUrl = @"Image/voice.png"; } } } protected void DirTreeview_SelectedNodeChanged(object sender, EventArgs e) { BindDirContents(this.DirTreeview.SelectedNode, this.gridviewFiles); } protected void gridviewFiles_RowCommand(object sender, GridViewCommandEventArgs e) { // handle either opening the item or rebinding the grid if (e.CommandName == "ItemClick") { string name = (string)e.CommandArgument; System.IO.DirectoryInfo dinfo = new System.IO.DirectoryInfo(this.DirTreeview.SelectedNode.Value); if (System.IO.File.Exists(System.IO.Path.Combine(dinfo.FullName, name))) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(System.IO.Path.Combine(dinfo.FullName, name)); // they clicked on a file, download it to there PC this.Response.Clear(); this.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name); this.Response.WriteFile(fileInfo.FullName); this.Response.End(); } else { foreach (TreeNode node in this.DirTreeview.SelectedNode.ChildNodes) { if (node.Text == name) { node.Selected = true; node.Expanded = true; // expand the parents TreeNode parentNode = node.Parent; while (parentNode != null) { parentNode.Expanded = true; parentNode = parentNode.Parent; } // bind the gridview to the datasource BindDirContents(node, this.gridviewFiles); break; } } } } } }
 
You have not Logged In,  click here to Login
Reply Here
 
, I agree the terms and conditions of this website
  
  .NET Framework
  ADO.NET
  AJAX
  Android
  ASP.NET
  ASP.NET AJAX
  ASP.NET MVC
  Azure
  Best Practices
  BizTalk Server
  C++
  CSharp
  CSS
  DBMS
  Error and Resolution
  HTML
  IIS
  JAVA
  JavaScript
  JQwery
  JSP
  LINQ
  Management
  Mobile
  ODP.NET
  OOPS
  Oracle
  Others
  Pattern and Practices
  PHP
  SAP
  SEO
  SharePoint
  Silverlight
  Sql Server
  SSAS
  SSIS
  SSRS
  Survey
  UML
  UNIX
  VB
  VB.NET
  VS 2010
  WCF
  Web Analytics
  Windows Forms
  WPF
  WWF
  XML
  XSLT
  .NET Framework
  ADO.NET
  AJAX
  Android
  ASP.NET
  ASP.NET AJAX
  ASP.NET MVC
  Azure
  Best Practices
  BizTalk Server
  C++
  CSharp
  CSS
  DBMS
  Error and Resolution
  HTML
  IIS
  JAVA
  JavaScript
  JQwery
  JSP
  LINQ
  Management
  Mobile
  ODP.NET
  OOPS
  Oracle
  Others
  Pattern and Practices
  PHP
  SAP
  SEO
  SharePoint
  Silverlight
  Sql Server
  SSAS
  SSIS
  SSRS
  Survey
  UML
  UNIX
  VB
  VB.NET
  VS 2010
  WCF
  Web Analytics
  Windows Forms
  WPF
  WWF
  XML
  XSLT

Advertise About Us Private Policy Terms of use
All rights reserved to dotnetcodes. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks.
Best viewed at 1024 x 768 resolution with Internet Explorer 5.0 or Mozila Firefox 3.5 or Google Crome and higher