|
-
Mar 11th, 2005, 04:55 AM
#1
Thread Starter
Fanatic Member
Copy File to LocalHost [RESOLVED]
I need to copy a file, on the web server, to the web page directory so it can be made available to download from the web page.
However, I need to do it in code. How do I findout the path to the web page folder in the localhost so that I can use the FileCopy command?
Last edited by simonm; Mar 11th, 2005 at 08:17 AM.
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Mar 11th, 2005, 07:53 AM
#2
Frenzied Member
Re: Copy File to LocalHost
You need to add a HtmlInputFile control onto a page to upload the file to the server.
Code:
void Upload_Click(Object sender, EventArgs e) {
if (fileUp.PostedFile.ContentLength > 0) {
fileUp.PostedFile.SaveAs("C:\uploadedFiles" + fileUp.PostedFile.FileName);
}
}
<input type="file" id="fileUp" runat="server" />
<asp:Button id="upload" runat="server" OnClick="Upload_Click" />
Obviously you can change the path to the directory you want to save to.
HTH
DJ
-
Mar 11th, 2005, 08:15 AM
#3
Thread Starter
Fanatic Member
Re: Copy File to LocalHost
No, the file I want is already on the server.
Anyway, my problem is resolved now.
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Mar 11th, 2005, 09:32 AM
#4
Frenzied Member
Re: Copy File to LocalHost [RESOLVED]
Sorry your description seemed to indicate you wanted to copy a file from localhost to the server.
If you have a chance post the solution you found so if anyone searches for a similar subject in the future the answer is here - I'm also interested to see what you were doing 
Cheers
DJ
-
Mar 11th, 2005, 11:26 AM
#5
Thread Starter
Fanatic Member
Re: Copy File to LocalHost [RESOLVED]
Returns the directory on the web server that contains my web page application.
Using this, I was able to copy a file from my "Temp" directory to my webhost directory like this:
VB Code:
strFileName = "Text.txt"
strTargetDirectory = Server.MapPath(strFileName)
FileSystem.FileCopy("C:\Temp\" & strFileName, strTargetDirectory)
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|