.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Asad Ali
Post New Web Links

rename the uploadcontrol filename?

Posted By:      Posted Date: October 05, 2010    Points: 0   Category :ASP.Net

Hi friends,

  I have a question. How do you rename a file from an upload control and save it in webserver folder?. Actually I know how to save it in the webfolder. All I want to know is how to check if the file already exist and to rename it if it exist with an addition of number to the file uploaded? Any help will highly appreciate.  Thanks Here is my code now. But I wanna add another number to it with the orignal file name.


filepath = Server.MapPath(

"~/Resumes/" & UploadResume.FileName)

View Complete Post

More Related Resource Links

Rename Filename



I am trying to change the name and filename of a database primary filegroup:

ALTER DATABASE [$(DatabaseName)]
 NAME = '$(DatabaseName)',
 NEWNAME = '$(DatabaseName)_Data',
 SIZE = 40MB,

ALTER DATABASE [$(DatabaseName)]
	NAME = '$(DatabaseName)_Data',
 FILENAME = '$(DefaultDataPath)$(DatabaseName)_Data.mdf'

The filegroup is renamed but the file in the data folder is not.

I tried various options including spiting this in two steps but it does not work.

How can I do this?



Rename Top Level Site Name MOSS2007


Hi techies,

      is there any possibility of renaming the TopLevel Site Name in MOSS2007.

Ex: www.Moss1.com to www.Moss2.com

thanks in advance.



Nag: http://nagaraju-sharepoint.blogspot.com. Posting is provided with no warranties.

filename without directory

how to insert the exact  filename to the database without getting the full directory like c://something/something/filename  into the column 'Filename'     waitng for reply

Capture the xml filename and load in a table

Hey I am having folder which contains multiple xml files.Now I need to read the xml file name and write in a table. I follwed the steps which are in the following link. http://www.sqlservercentral.com/articles/SSIS/67871/ But I am getting data as well as. I need only the file name to be written in a table.

FileStreamResult how to rename the output file?????

i have an action to return a pdf file in my controller,if the return file is for downloading, the following code can be used to modify filename successfully.HttpContext.Response.AddHeader("content-disposition", "attachment; filename=form.pdf");HOWEVER, i found that when the pdf file was returned to browser( rather than a pop up window to download), the filename always remain same as the action name! (when u right click file and try to save it on ur hard disk), i was wondering if there is a automatic way to rename the file rather than "right click" and "save as" manually.so  can anyone tell me how to rename the outputfile when it is shown in the browser?

problem rename sharepoint 2010 search service application admin database

Hi all, i have a problem that hopefully someone has an answer to.  i am not too familiar with sharepoint so please excuse my ignorance. we have sharepoint 2010 on a windows 2008r2 server.  everything seems to work fine.  but as you know, the default database names are horrendous.  i have managed to rename all of them, except for the "search service application" admin database. the default is: Search_Service_Application_DB_<guid> the other 2 databases (crawl and property) were renamed without a problem. we are following the article from technet on how to rename the search service admin db (http://technet.microsoft.com/en-nz/library/ff851878%28en-us%29.aspx).  it says to enter the following command: $searchapp | Set-SPEnterpriseSearchServiceApplication -DatabaseName "new database name" -DatabaseServer "dbserver" however, i get an error about identity being null.  no big deal, i add the -Identity switch and the name of my search service application.  but the real problem comes the error it throws:   Set-SPEnterpriseSearchServiceApplication : The requested database move was aborted as the associated search application is not paused. At line:1 char:54 + $searchapp | Set-SPEnterpriseSearchServiceApplication <<<<  -Identity "Search Service Application" -DatabaseName "ShareP

Rename a column in multiple Tables using sp_rename

Hi,Any work around for the below issue?Originally "LoadDate" column (see below scripts) was there both in tables DIM_Table_1 and DIM_Table_2According to change in requirement, LoadDate in both the tables to be chnged to LOAD_DATE. It has to be done through script-----------------EXEC sp_rename 'dbo.DIM_Table_1.LoadDate',     'LOAD_DATE', 'COLUMN'         -- Successfully executedEXEC sp_rename 'dbo.DIM_Table_2.LoadDate',     'LOAD_DATE', 'COLUMN'         -- Error: See below Error: The new name 'LOAD_DATE' is already in use as a COLUMN name and would cause a duplicate that is not permitted.-----------------

Rename File on Harddisk???

Hi,    I have around 1000 image file in One folder...out of that i have around 400 image file with filename which contains '&' and i have to remove or '&' or rename the filename.... i have to create small application for this scenario...How to do??? any idea?? abhi

How do you rename a document in Batch Update?

Hi, I have tried to rename a file as so. xml += "<Method ID='" + currentID + "' Cmd='Update'>"; xml += "<Field Name='ID'>" + ID + "</Field>"; xml += "<Field Name='FileRef'>" + fileRef + "</Field>";   xml += "<Field Name='LinkFilename'>" + "Accommodation.pdf" + "</Field>"; </Method> I have tried Name instead of LinkFilename and still no joy. Can anyone help. Thanks. John.

how to inherit value type or rename it

Dear Everyone. i know not to inherit value type, i need to change the name of value type to any Name. for example) int i = 0;  ---> i want to change it to like below S32 i = 0; so i have tried to inherit value type, but i can't inherit it , because the type is struct type. Someone have a idea what i want to do. Thanks.    lightdoll

Rename SPListItem file with extention

Hi guys,   I'm working with a simple workflow that is fired when a item has been added. workflow code is currenlty very simple..     Suppose that I upload original.doc. Following code will rename it to renamed.doc. I cannot find any way to rename "doc" extention to sth else.   Any ideas ? private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e) { workflowProperties.Item["Name"] = "renamed.xml"; // .xml extention is ignored! workflowProperties.Item.SystemUpdate(); }  

Rename a document in Doc Library without changing the modified by

How do I rename the document in the document library without changing the modifed by and no increment of version? My Document Library setting is Major Version and CheckOut is set to No. I'm using SPSecurity.RunWithElevatedPrivileges to rename the document I had tested to checkout then checkin but there is an increment in version. Here is a sample code that will rename the filename but the modified by changed to System Account. SPSecurity.RunWithElevatedPrivileges(new SPSecurity.CodeToRunElevated(delegate() { using (SPSite elevatedSite = new SPSite(SPContext.Current.Site.ID)) { using (SPWeb elevatedWeb = elevatedSite.OpenWeb(SPContext.Current.Site.RootWeb.ID)) { elevatedWeb.AllowUnsafeUpdates = true; SPList list = elevatedWeb.Lists["Library1"]; SPListItem item = list.GetItemById(documentID); if (updateFilename) item["Name"] = filename; item.SystemUpdate(); } } })); Is there anyone out there who can help? Thanks in advanced.

How to rename the document using event receiver during upload

Hi all, I am going to programmaticlly rename the document when it is being uploaded to the document library. In Visual Studio 2010, I used the event receiver and choosed the documment libray type, for the event I selected 'ItemAdding". However I am not able to update the file name using the codes inside this thread: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/5c3dcc5d-3113-463d-8835-2a050b2471a6/ Can anyone help me with this problem? Thanks!

Error: Internet Explorer Cannot Download FileName from WebServer

I am trying to display documents (.Doc / .PDF) through my web page.The code works fine in FireFox, but gives an error message on IE 6.0 / 7.0 / 8.0 Context.Response.Buffer = true;Context.Response.Clear();Context.Response.BufferOutput = false;Context.Response.ContentType = File.GetContentType(File.FileName);Response.AppendHeader("Pragma", "public");Response.AppendHeader("Cache-Control", "max-age=0");Response.Charset = "";Context.Response.AddHeader("content-length", File.FileData.Length.ToString());Context.Response.AddHeader("content-disposition", File.GetContentDisposistion(File.FileName)); Context.Response.BinaryWrite(imageFileBase.FileData);Context.Response.Flush();Context.Response.End();

How to show a message box on an invalid filename entered while saving a file using save file dialog

Hi all i have written a code to display a message box if invalid characters are entered while saving the file but my message box is not displaying. Actually i will have a save file dialog option to save a file if the filename starts or consists of the following    \\/:*?<>|"  I would like to display a message box as invalid or illegalcharacters in file My code is as follows    Stream myStream;                          SaveFileDialog saveFileDialog1 = new SaveFileDialog();                            saveFileDialog1.InitialDirectory = @"C:\";                          saveFileDialog1.DefaultExt = "txt";                          saveFileDialog1.Filter = "(*.txt)|*.txt";                          saveFileDialog1.FilterIndex = 2;                          saveFileDialog1.RestoreDirectory = true;                            if (saveFileDialog1.ShowDialog() == DialogR

merging two textfiles along with filename

Hi Team, I wantto build a package which takes input from .txt files and write in abc.txt along wiht the file name so if input is file a.txt content is lksjklsslkjfksf sfjsdkjflsd file b.txt content is lksjklsslkjfksf sfjsdkjflsd  then output abc.txt should be a.txt lksjklsslkjfksf sfjsdkjflsd b.txt lksjklsslkjfksf sfjsdkjflsd   Please give me some suggsetion on how to do it its like inserting file name then data in the same column Regars, Eshwar    

Sql server 2005 - rename cluster to an old cluster name

We have a sql 2005 cluster on W2K8 cluster. It is a named instance say SRV1\A. Then I built a new W2K8 (with a diff cluster service name) but the same service account. Then I installed a new sql 2005 cluster say SRV2\A. Now when I bring down the sql server resources on SRV1 and try to rename SRV2\A to SRV1\A through the cluster admin, I get the error the network name already exists. I have tried bringing an old cluster and installing a new cluster with the same name and it works. Why am I not able to rename the name? Any advice would very helpful.Paul - SQL DBA
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend