• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Uploading saved files in asp.net

Hi experts!

I'm trying to upload a saved pdf file to webserver but the server is returning an error 404: not found. The IIS 7 is running on my machine where I'm administrador and the folder App has permittion to Everybody (full). I try too include ASPNET user on folder security. For the download process everything works fine but for upload the error appears.

The partial code:

WebClient WebClient = new WebClient();
WebClient.Credentials = CredentialCache.DefaultNetworkCredentials;

string LocalFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "File1.pdf");

WebClient.DownloadFile("http://localhost/App/File1.pdf", LocalFile); /* it works fine */
WebClient.UploadFile("http://localhost/App/File2.pdf", LocalFile); /* it not works */

Any suggestions?
Thanks in advance!
0
ZumbaJr
Asked:
ZumbaJr
  • 2
1 Solution
 
masterpassCommented:
I think you are referring to the filename in here

WebClient.UploadFile("http://localhost/App/File2.pdf", LocalFile); /* it not works */

try like this :

WebClient.UploadFile("http://localhost/App", LocalFile);

Hope this helps :)
0
 
deepu chandranCommented:
Have a look at this article,looks like useful for you

http://www.codeproject.com/Articles/8600/UploadFileEx-C-s-WebClient-UploadFile-with-more-fu 

--Deepu
0
 
ZumbaJrAuthor Commented:
Hi folks!

The questions that I didn't understood yet is: the UploadFile FileName must be in application machine, not client machine. When I run DownloadFile it downloaded too the application machine. In my case, the same machine, here is the confusion. When I run the application from other host, the files still remains in application machine and when I run UploadFile method with filename paths on the application machine it works. But I'm looking for a method that upload files from Client Machine to Application Machine without use file form field to do it, only indicating the local path.

Thanks very much!
0
 
masterpassCommented:
I did not quite get your question but once the application goes to production, you are most likely to have an address say www.xyz.com which is going to static and so the webclient should work just fine.

alternatively, you can look at fileupload control which uploads files from client machine to server : http://www.codeproject.com/Articles/1757/File-Upload-with-ASP-NET

hope this helps :)
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now