Forums » .NET » .NET »

How to give default file path in textbox of fileupload


Posted Date: 04 Aug 2009      Posted By:: suhasini     Member Level: Bronze    Member Rank: 0     Points: 1   Responses: 1



Hi,
I am working on c# 2.0 web application. Im my application I have to upload file from client machine to server machine .
So I am using file upload control to upload file.
I have to give default file to upload("C:\EmailPrisma1\test.txt") .without using browse button.
How to give default file path in Textbox of fileUpload

error:
FileUpload1.FileName = clientfilepath;
Property or indexer 'System.Web.UI.WebControls.FileUpload.FileName' cannot be assigned to -- it is read only



string msg;
if (FileUpload1.HasFile)
try
{
string clientfilepath = "";
clientfilepath = Request.QueryString["FilePath"];
//FileInput.PostedFile.SaveAs(MapPath(".") + serverFileName);
//FileInput.PostedFile.FileName == ""
clientfilepath = @"C:\EmailPrisma1\test.txt";
FileUpload1.FileName = clientfilepath;
Property or indexer 'System.Web.UI.WebControls.FileUpload.FileName' cannot be assigned to -- it is read only
FileUpload1.SaveAs("C:\\EmailPrisma1\\" + FileUpload1.FileName);
msg = "File name: " +
FileUpload1.PostedFile.FileName + "<br>" +
FileUpload1.PostedFile.ContentLength + " kb<br>" +
"Content type: " +
FileUpload1.PostedFile.ContentType;
}
catch (Exception ex)
{
msg = "ERROR: " + ex.Message.ToString();

}
else
{
msg = "You have not specified a file.";

}
}






Responses

#409660    Author: Prathap Reddy      Member Level: Gold      Member Rank: 1743     Date: 04/Aug/2009   Rating: 2 out of 52 out of 5     Points: 2

File upload --> File Name is ReadOnly and We can not assign a default value to FileUpload control.

 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Birthday wish email alert
Previous : Compare textbox values
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India