<table class="style1">
<tr>
<td>
<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>
</td>
<td>
<asp:TreeView ID="TreeView1" runat="server">
</asp:TreeView>
</td>
<td>
<asp:ListBox ID="ListBox2" runat="server"></asp:ListBox>
</td>
</tr>
</table>
How to get all available local drive names in listbox1 and its folders in treeview and their file formats with extensions in listbox2??
There are few sources where i can find them..but...they are available in VB. http://blogs.technet.com/b/heyscriptingguy/archive/2007/09/20/how-can-i-dynamically-show-available-drive-letters-in-a-list-box.aspx.
if you want to get the local drives of a user: That's
not possible in ASP.NET (because it's a server-side technology). You could Silverlight for that purpose.
Regards.
If my post solves your problem, please mark as answer.
Yea, I mean there is ways to do this in ASP.NET via downloadable client apps or ActiveX controls but no client browser is going to just let your app have this kind of access without a fuss lol.
When the going get's tough, the tough outsource and take a vacation... lol I wish :(
foreach (var item in Directory.GetFiles("C:\\","*.*",SearchOption.TopDirectoryOnly))
{
Response.Write(item);
}
How could i get all the files in listbox when i select treeview's node
sinhaify
Member
82 Points
67 Posts
How can i get them using c#(asp.net)
Jan 17, 2012 03:09 PM|LINK
<table class="style1"> <tr> <td> <asp:ListBox ID="ListBox1" runat="server"></asp:ListBox> </td> <td> <asp:TreeView ID="TreeView1" runat="server"> </asp:TreeView> </td> <td> <asp:ListBox ID="ListBox2" runat="server"></asp:ListBox> </td> </tr> </table> How to get all available local drive names in listbox1 and its folders in treeview and their file formats with extensions in listbox2?? There are few sources where i can find them..but...they are available in VB. http://blogs.technet.com/b/heyscriptingguy/archive/2007/09/20/how-can-i-dynamically-show-available-drive-letters-in-a-list-box.aspx.Horizon_Net
Star
8309 Points
1441 Posts
Re: How can i get them using c#(asp.net)
Jan 17, 2012 04:05 PM|LINK
Hi,
if you want to get the local drives of a user: That's not possible in ASP.NET (because it's a server-side technology). You could Silverlight for that purpose.
If my post solves your problem, please mark as answer.
magicmike201...
Contributor
2021 Points
481 Posts
Re: How can i get them using c#(asp.net)
Jan 17, 2012 09:35 PM|LINK
Yea, I mean there is ways to do this in ASP.NET via downloadable client apps or ActiveX controls but no client browser is going to just let your app have this kind of access without a fuss lol.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How can i get them using c#(asp.net)
Jan 19, 2012 12:42 AM|LINK
Hello:)
1)For getting all the drivers,you can try to use System.IO.Driver class:
foreach (var item in DriveInfo.GetDrives()) { Response.Write(item.Name); }2)For getting all the files that belong to the specific driver,you can try to use System.IO.File class:
foreach (var item in Directory.GetFiles("C:\\","*.*",SearchOption.TopDirectoryOnly)) { Response.Write(item); }3)Besides this,you can also have a look at this sample:http://www.codeproject.com/KB/aspnet/WebFileManager.aspx
Horizon_Net
Star
8309 Points
1441 Posts
Re: How can i get them using c#(asp.net)
Jan 19, 2012 08:29 AM|LINK
If you want to do it on the server where your application is hosted go with the solution above.
If my post solves your problem, please mark as answer.
sinhaify
Member
82 Points
67 Posts
Re: How can i get them using c#(asp.net)
Jan 19, 2012 09:19 AM|LINK
foreach (var item in Directory.GetFiles("C:\\","*.*",SearchOption.TopDirectoryOnly)) { Response.Write(item); } How could i get all the files in listbox when i select treeview's nodeDecker Dong ...
All-Star
118619 Points
18779 Posts
Re: How can i get them using c#(asp.net)
Jan 19, 2012 11:44 PM|LINK
Hello again:)
I've shown you the codes above,and GetFiles is just what you want——Make sure that your treeview's node is a path (absolute or relative)。
Reguards!