Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0
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
 
 
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 6-Feb-13 0:26am
N@veen.S1.6K
Edited 6-Feb-13 1:11am
v2

1 solution

Rate this: bad
good
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).
  Permalink  
Comments
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 562
1 Sergey Alexandrovich Kryukov 484
2 Maciej Los 325
3 DamithSL 233
4 Mathew Soji 195
0 OriginalGriff 7,168
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,461
3 Manas Bhardwaj 4,876
4 Maciej Los 4,450


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2014
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