Solved

Uploading saved files in asp.net

Posted on 2013-01-16
4
225 Views
Last Modified: 2013-02-28
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
Comment
Question by:ZumbaJr
  • 2
4 Comments
 
LVL 21

Expert Comment

by:masterpass
Comment Utility
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
 
LVL 8

Expert Comment

by:deepu chandran
Comment Utility
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
 

Author Comment

by:ZumbaJr
Comment Utility
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
 
LVL 21

Accepted Solution

by:
masterpass earned 500 total points
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now