---
title: "rename files to upload to server ASP.NET"  
description: "rename files to upload to server ASP.NET"  
author: "Anonymous User"  
published: 2014-08-21  
updated: 2014-08-21  
canonical: https://www.mindstick.com/forum/2065/rename-files-to-upload-to-server-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# rename files to upload to server ASP.NET

I need to [rename](https://www.mindstick.com/interview/23303/how-to-rename-extention-of-mdf-file) the [files](https://www.mindstick.com/articles/23302/the-importance-and-advantage-of-keeping-your-important-files-on-the-cloud) before uploading them to my [local](https://www.mindstick.com/forum/546/how-to-create-local-user-in-windows-8) directory.

How I can do this this?

## Replies

### Reply by Sumit Kesarwani

Hi Chintoo, \
try this:

protected void button1_Click(object sender, EventArgs e){

string directory = Server.MapPath("uploads");

string fExtension = Path.GetExtension(FileUpload1.PostedFile.FileName);

string fileName = "newFileName" + fExtension;

this.FileUpload1.SaveAs(Path.Combine(directory,fileName));

}

Hope this will solve your problem


---

Original Source: https://www.mindstick.com/forum/2065/rename-files-to-upload-to-server-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
