By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,584 Members | 1,065 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,584 IT Pros & Developers. It's quick & easy.

upload files

P: n/a
I want to upload files without file control.

suppose i have string "c:\test.txt"

i am using this

FileInfo Myfile= new System.IO.FileInfo("c:\test.txt");

string strBaseLocation = "c:\\amit\\";

objFile=(HttpPostedFile)Myfile; there is an error in this line cant
cast like this

objFile.SaveAs(strBaseLocation+Myfile.FullName);

please help me

Nov 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
sonu,

Are you trying to copy the file on the local machine? Or to the c:\amit
directory on a web server (I don't know why you are using the HttpPostedFile
type).

If you want to upload a file to a website, you should use the UploadFile
method on the WebClient class. If you want to copy a file, then you want to
check the static Copy method on the File class.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sonu" <kr*******@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I want to upload files without file control.

suppose i have string "c:\test.txt"

i am using this

FileInfo Myfile= new System.IO.FileInfo("c:\test.txt");

string strBaseLocation = "c:\\amit\\";

objFile=(HttpPostedFile)Myfile; there is an error in this line cant
cast like this

objFile.SaveAs(strBaseLocation+Myfile.FullName);

please help me

Nov 17 '05 #2

P: n/a
I am tring to upload the file on webserver from client.
i want upload files from client to server with out using file control.
please give me link or sample of code about that.

Nov 17 '05 #3

P: n/a
sonu,

Check out the documentation for the UploadFiles method on the WebClient
class. It should give you an idea how to do this.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sonu" <kr*******@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I am tring to upload the file on webserver from client.
i want upload files from client to server with out using file control.
please give me link or sample of code about that.

Nov 17 '05 #4

P: n/a
Nicholas,

I tried and found this erroe

"The remote server returned an error: (405) Method Not Allowed."

what is the problem.

Nov 17 '05 #5

P: n/a
Sonu,

Files can be posted in a number of ways. You can issue a POST or a PUT.
Are you sure that the website that you are uploading to allows files
supports this?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sonu" <kr*******@yahoo.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Nicholas,

I tried and found this erroe

"The remote server returned an error: (405) Method Not Allowed."

what is the problem.

Nov 17 '05 #6

P: n/a
Thanks Nicholas, for giving the valuable information

I Had to write the Reciever side code also for uploading the file.
i did that and find result.
Sonu

Nov 17 '05 #7

P: n/a
Nicholas i want to System property like java "System.Getproperty()"

Actualy i want to know the loged person name.

Any information?

Nov 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.