Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm doing Excel Data Upload into SQL DB, for this i'm doing all the stuff, it's working fine for me also...

Now , my question is whenever i upload the different excel file's , i want to save any excel having a unique name...

Ex:

I'm try to upload A.xls,B.xls..., but the file should be saved in folder as xxx.xls.

this is the code for saving the excel

C#
FileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
string Extension = Path.GetExtension(FileUpload1.PostedFile.FileName);
string FolderPath = ConfigurationManager.AppSettings["DMSFolder"];
FilePath = Server.MapPath(FolderPath + FileName);
ViewState["FilePath"] = FilePath;
ViewState["FileName"] = FileName;
FileUpload1.SaveAs(FilePath);


How to achieve this ....

But one more thing after save the file i want to display the available sheets in that excel . so, whatever we implement for that it's wont effect to existing ...

can any body give me some suggestion...

Thanks in Advance....
Posted
Updated 6-Feb-13 0:11am
v2

1 solution

You could go ahead and add date and time (or a serial number) to make the file name unique.
A GUID[^] would be the most unique item (but I guess that would be overkill for your requirement).
 
Share this answer
 
Comments
Naveen.Sanagasetti 6-Feb-13 6:09am    
Sorry Abhinav i'm asking i upload any type of file name but i want to save the file name as xxx.xls. But one thing after save the file i displayed the sheet names available in that excel . If we change some thing in file name it wont effect on existing.
joe_j 6-Feb-13 7:11am    
Could you please make the question more clear? Not quite clear about the requirement.

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