Click here to Skip to main content
11,802,205 members (55,885 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET C#4.0

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...


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

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;

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 5-Feb-13 23:26pm
Edited 6-Feb-13 0:11am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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).
naveensenagasetti at 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 at 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)

  Print Answers RSS
0 OriginalGriff 475
1 KrunalRohit 341
2 F-ES Sitecore 295
3 Afzaal Ahmad Zeeshan 230
4 CHill60 195
0 OriginalGriff 2,715
1 Maciej Los 1,900
2 KrunalRohit 1,797
3 CPallini 1,550
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100