http file upload from c# windows application

J

JohnSouth

I've a C# windows application (not asp.net) that needs to upload
simple XML files to a URL on a website.

I've tried WebClient such as

WebClient Client= new WebClient();
Client.UploadFile(url,filePath);

but get error (405) Method not allowed.

I've got write permissions set on the remote folder. Do I need
identity impersonate=true?
I know how to set this in a web config in asp.net but not in a C#
windows application.

Any suggestions.

John South
WhereCanWeGo.com
 
J

Joerg Jooss

Thus wrote JohnSouth,
I've a C# windows application (not asp.net) that needs to upload
simple XML files to a URL on a website.

I've tried WebClient such as

WebClient Client= new WebClient();
Client.UploadFile(url,filePath);
but get error (405) Method not allowed.

I've got write permissions set on the remote folder. Do I need
identity impersonate=true?
I know how to set this in a web config in asp.net but not in a C#
windows application.
Any suggestions.

If you're trying to write directly to the host (i.e. there's no web application
in between receiving the file), use
client.UploadFile(url, "PUT", filePath);

Also, make sure that "url" contains the actual filename to put the file to,
i.e. http://host/path/to/foo.txt.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top