Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 24th, 2006, 05:27 AM
Authorized User
 
Join Date: Mar 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to create a folder in server and rename files

Hello friends..,

Greetings!!!!!
 I have an application(client) from which i upload files to the server. I did that upload part. But now i have a problem with that. In my application different users login and upload their files. For each user their will be seperate login.

The problem is that i need to create a folder in the server spontaneously when a particular user tries to upload a file and also i need to rename that file when it is saved in that folder so that if the user tries to upload a file again with the same name it should not be overwritted.I am giving the code that i used to upload below:


protected void Button1_ServerClick(object sender, EventArgs e)
    {
        //Uploading the attached file
if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
        {
            string fn = System.IO.Path.GetFileName(File1.PostedFile.FileNa me);
            string SaveLocation = Server.MapPath("Data") + "\\" + fn;
            try
            {

                File1.PostedFile.SaveAs(SaveLocation);
                Response.Write("file Uploaded");

            }
            catch (Exception ex)
            {
               Response.Write("Error:" + ex.message);
    //Note: Exception.Message returns a detailed message that describes the current exception.

            }
        }
        else
        {


        Response.Write("Please select a file to upload.");

        }


    }



so guys please help me for the above problem as early as possible.


Thanks & Regards,

Pramod.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Rename web site, aspx, folder in VS 2005? cJeffreywang BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 0 July 9th, 2007 11:40 AM
Create backup folder & also backup files miracles Excel VBA 0 April 16th, 2007 02:28 AM
Rename File/Folder shivanshub C# 17 August 19th, 2006 09:48 AM
Rename File/Folder shivanshub General .NET 0 August 11th, 2006 01:57 PM
Rename external files from within access timmaher Access VBA 1 March 24th, 2004 10:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.