Click here to Skip to main content
15,904,503 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have write a code to upload the pdf file in the database and now i want to edit the upload loaded file during this an error occur ...any one can tell how to remove this error
the error in this line


FileUpload1.PostedFile.FileName= dt.Rows[0]["SelectedFile"].ToString();
Posted
Comments
[no name] 30-Aug-14 14:53pm    
There is more than one error message and we cannot see your screen to know which one you are seeing.
Afzaal Ahmad Zeeshan 30-Aug-14 15:30pm    
You've not provided enough details to work on your question. Sorry!

1 solution

FileName is read only property. You are trying to set the name to the FileName property of fileupload control which is not possible. So that line will throw an compile time error.
Secondly, you can not edit submitted file in this way. If you want to edit (name of file),delete file which you have already uploaded, better you can use primary ID for that.
for example :
you can store files using 2 methods :
1] you can store bytes into the table with primary ID than by using primary ID you can change that file name or delete bytes.
2] you can also save the file path instead of bytes and store file physically using same id. so you can edit or delete using primary ID in sql table and also in file system (where you actual file is uploaded) using File class.

Both methods have there advantages and disadvantages but from the performance point of view second method is always preferable.

Thanks,
Suraj
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900