C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Training   ASP.NET Web Hosting    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

Play Silverlight Games or Submit your Silverlight applications and earn 90% AdSense revenue.

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Forums » .NET » .NET »

asp.net copy file


Posted Date: 08 Mar 2006      Posted By: dotnet      Member Level: Gold     Points: 2   Responses: 1



hi
i wanna kwno how to copy a file a partcular lcation
thanks in adavance
pervej munja





Responses

Author: MuniHemadriBabu.Jogi    09 Mar 2006Member Level: GoldRating:     Points: 2

Hi

html code:
<code>
<html>
3 <head>
4 <style TYPE="text/css">
5 body {
6 font-family: Verdana;
7 font-size: 70%;
8 }
9 table tr td {
10 font-family: Verdana;
11 font-size: 70%;
12 }
13 </style>
14 </head>
15
16 <body>
17 <h4>Copying a Directory with ASP.NET</h4>
18 <form runat="server">
19 <table border="0" cellpadding="3" cellspacing="2" bgcolor="#cccccc">
20 <tr>
21 <td>Type the source directory:</td>
22 <td><asp:TextBox Runat="server" ID="tbxSourceDir"></asp:TextBox></td>
23 </tr>
24 <tr>
25 <td>Type the destination directory:</td>
26 <td><asp:TextBox Runat="server" ID="tbxDestinationDir"></asp:TextBox></td>
27 </tr>
28 <tr>
29 <td colspan="2"><asp:Button Runat="server" ID="btnCopy" OnClick="Copy_Click" Text="Click to Copy"></asp:Button></td>
30 </tr>
31 </table>
32 <br>
33 <asp:Label Runat="server" ID="lblStatusMessage" Visible="False" ForeColor="#ff0000"></asp:Label>
34 </form>
35 </body>
36 </html>
</code>

button_Click code
<%@ Page Language="vb" debug="true" explicit="true" strict="true" %>
2 <script language="vb" runat="server">
3 Sub Copy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
4 'convert our source path into a physical path
5 Dim sourcePath As String = Server.MapPath(tbxSourceDir.Text)
6 'get the folder we want to copy from
7 Dim arrSourcePath() As String = RegEx.Split(tbxSourceDir.Text, "/")
8 Dim lastFolder As String = arrSourcePath(UBound(arrSourcePath))
9 'get our destination path as physical
10 Dim destPath As String = Server.MapPath(tbxDestinationDir.Text + "/" + lastFolder)
11 Try
12 CopyDirectory(sourcePath, destPath, True)
13 Catch exc As System.Exception
14 lblStatusMessage.Text = exc.Message
15 lblStatusMessage.Visible = True
16 End Try
17 End Sub



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Is there any expert to solve this?
Previous : what is difference between String and string(data type) in c#?
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use