Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > file copy question

Reply
Thread Tools

file copy question

 
 
Paul
Guest
Posts: n/a
 
      06-12-2008
Hi just wondering if there is any sample code to copy files from one
directory into another with the code behind a button click event? Using c#
vs2005.
Thanks.
--
Paul G
Software engineer.
 
Reply With Quote
 
 
 
 
Juan T. Llibre
Guest
Posts: n/a
 
      06-12-2008
You need to import the System.IO namespace :

<%@ Import Namespace="System.IO" %>

Then, for your code :

File.Copy("C:\\Dir1\\file.ext", @"C:\AnotherDir\file.ext");

Feel free to substitute variables for the actual paths.
You can also use different drives.

Make sure your ASP.NET account has write permissions
to the directory where the file is being copied to.






Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Paul" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hi just wondering if there is any sample code to copy files from one
> directory into another with the code behind a button click event? Using c#
> vs2005.
> Thanks.
> --
> Paul G
> Software engineer.




 
Reply With Quote
 
 
 
 
Juan T. Llibre
Guest
Posts: n/a
 
      06-12-2008
I noticed, after posting, that you requested code-behind and C#.

Instead of "importing", add the reference to System.IO to your code-behind :

using System.IO;




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> You need to import the System.IO namespace :
>
> <%@ Import Namespace="System.IO" %>
>
> Then, for your code :
>
> File.Copy("C:\\Dir1\\file.ext", @"C:\AnotherDir\file.ext");
>
> Feel free to substitute variables for the actual paths.
> You can also use different drives.
>
> Make sure your ASP.NET account has write permissions
> to the directory where the file is being copied to.
>
>
>
>
>
>
> Juan T. Llibre, asp.net MVP
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ======================================
> "Paul" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> Hi just wondering if there is any sample code to copy files from one
>> directory into another with the code behind a button click event? Using c#
>> vs2005.
>> Thanks.
>> --
>> Paul G
>> Software engineer.

>
>
>



 
Reply With Quote
 
Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
Guest
Posts: n/a
 
      06-12-2008
How about this?
http://msdn.microsoft.com/en-us/libr...py(VS.71).aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
http://iPhonePlaza.net


"Paul" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi just wondering if there is any sample code to copy files from one
> directory into another with the code behind a button click event? Using
> c#
> vs2005.
> Thanks.
> --
> Paul G
> Software engineer.


 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      06-12-2008
Thanks for the responses, looks like it is easy to impliment once you have
the correct namespace.
--
Paul G
Software engineer.


"Steve C. Orr [MCSD, MVP, CSM, ASP Inside" wrote:

> How about this?
> http://msdn.microsoft.com/en-us/libr...py(VS.71).aspx
>
> --
> I hope this helps,
> Steve C. Orr,
> MCSD, MVP, CSM, ASPInsider
> http://SteveOrr.net
> http://iPhonePlaza.net
>
>
> "Paul" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi just wondering if there is any sample code to copy files from one
> > directory into another with the code behind a button click event? Using
> > c#
> > vs2005.
> > Thanks.
> > --
> > Paul G
> > Software engineer.

>

 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      06-12-2008
Hey, Steve, don't you hate it when code samples refer only to console apps ?

I bet that has created many headaches for people looking for ASP.NET samples.
It's easy for a beginner to stub his toe on the sample's translation to web app code.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How about this?
> http://msdn.microsoft.com/en-us/libr...py(VS.71).aspx
>
> --
> I hope this helps,
> Steve C. Orr,
> MCSD, MVP, CSM, ASPInsider
> http://SteveOrr.net
> http://iPhonePlaza.net
>
>
> "Paul" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> Hi just wondering if there is any sample code to copy files from one
>> directory into another with the code behind a button click event? Using c#
>> vs2005.
>> Thanks.
>> --
>> Paul G
>> Software engineer.

>



 
Reply With Quote
 
David Wier
Guest
Posts: n/a
 
      06-12-2008
It sure stubbed my toes a number of times, when I was first starting to
learn ASP.Net - I had no idea what a console app was - and then when I did
find out, it made me furious, since so many samples were written this way

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup


"Juan T. Llibre" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hey, Steve, don't you hate it when code samples refer only to console apps
> ?
>
> I bet that has created many headaches for people looking for ASP.NET
> samples.
> It's easy for a beginner to stub his toe on the sample's translation to
> web app code.
>
>
>
> Juan T. Llibre, asp.net MVP
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ======================================
> "Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
>> How about this?
>> http://msdn.microsoft.com/en-us/libr...py(VS.71).aspx
>>
>> --
>> I hope this helps,
>> Steve C. Orr,
>> MCSD, MVP, CSM, ASPInsider
>> http://SteveOrr.net
>> http://iPhonePlaza.net
>>
>>
>> "Paul" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Hi just wondering if there is any sample code to copy files from one
>>> directory into another with the code behind a button click event? Using
>>> c#
>>> vs2005.
>>> Thanks.
>>> --
>>> Paul G
>>> Software engineer.

>>

>
>



 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      06-12-2008
Yep in the past not noticing an example is a windows app I will start trying
to impliment it in a web app until I can not find the class or namespace that
they are using in the example!
--
Paul G
Software engineer.


"Juan T. Llibre" wrote:

> Hey, Steve, don't you hate it when code samples refer only to console apps ?
>
> I bet that has created many headaches for people looking for ASP.NET samples.
> It's easy for a beginner to stub his toe on the sample's translation to web app code.
>
>
>
> Juan T. Llibre, asp.net MVP
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ======================================
> "Steve C. Orr [MCSD, MVP, CSM, ASP Insider]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > How about this?
> > http://msdn.microsoft.com/en-us/libr...py(VS.71).aspx
> >
> > --
> > I hope this helps,
> > Steve C. Orr,
> > MCSD, MVP, CSM, ASPInsider
> > http://SteveOrr.net
> > http://iPhonePlaza.net
> >
> >
> > "Paul" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >> Hi just wondering if there is any sample code to copy files from one
> >> directory into another with the code behind a button click event? Using c#
> >> vs2005.
> >> Thanks.
> >> --
> >> Paul G
> >> Software engineer.

> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File::Copy::copy With File Handles MaggotChild Perl Misc 2 10-22-2011 12:15 AM
unicode shutil.copy() changes a file name during copy? dave Python 6 02-16-2011 09:53 PM
what is Deep Copy, shallow copy and bitwises copy.? saxenavaibhav17@gmail.com C++ 26 09-01-2006 09:37 PM
is dict.copy() a deep copy or a shallow copy Alex Python 2 09-05-2005 07:01 AM
using File.Copy to copy files to shared hosting site Steve Richter ASP .Net 4 04-18-2005 03:06 PM



Advertisments