Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Naming a file on the server in Multiuser environment.

Naming a file on the server in Multiuser environment.

Scheduled Pinned Locked Moved ASP.NET
sysadminworkspace
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KittyKit
    wrote on last edited by
    #1

    Hello there I've a website that allows a user to create and download a document. I first save the file in the server and then let the user download it. This works just fine. But when multiple users try to do this, they must create their own copy of the file in the server. Can somebody suggest a foolproof way of naming the file - so that everyuser downloads only their copy of the file. Many thanks in advance.

    B S A V 4 Replies Last reply
    0
    • K KittyKit

      Hello there I've a website that allows a user to create and download a document. I first save the file in the server and then let the user download it. This works just fine. But when multiple users try to do this, they must create their own copy of the file in the server. Can somebody suggest a foolproof way of naming the file - so that everyuser downloads only their copy of the file. Many thanks in advance.

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      One of possibilities is: string uniqueFileName = Guid.NewGuid().ToString();


      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

      K 1 Reply Last reply
      0
      • K KittyKit

        Hello there I've a website that allows a user to create and download a document. I first save the file in the server and then let the user download it. This works just fine. But when multiple users try to do this, they must create their own copy of the file in the server. Can somebody suggest a foolproof way of naming the file - so that everyuser downloads only their copy of the file. Many thanks in advance.

        S Offline
        S Offline
        S Brozius
        wrote on last edited by
        #3

        How about naming the file with the username as a part of it? Or possibly a date-time-string such as 'yyyyMMddHHmmss' or a combination of the two?

        Nah... What's up, Doc? CCC's solved : 1 If a bus station is where a bus stops, and a train station is where a train stops, why do I have a work station on my desk?

        1 Reply Last reply
        0
        • K KittyKit

          Hello there I've a website that allows a user to create and download a document. I first save the file in the server and then let the user download it. This works just fine. But when multiple users try to do this, they must create their own copy of the file in the server. Can somebody suggest a foolproof way of naming the file - so that everyuser downloads only their copy of the file. Many thanks in advance.

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          Of course.. Pad the UniqueID(Preferably a GUID) just after the actual filename. It will identify which users copy of the file it is. Also, if your requirement is only to have a copy, why dont you use Database as file storage. It is easier to manage files in database as far as your reqirement is concerned. Only a single row with UserID Foreign key will do the job for you. Also, another thing, if the file wouldn't be modified by each user in the server, you dont have to store multiple copies of each file. :)

          Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


          My Latest Articles-->** Simplify Code Using NDepend
          Basics of Bing Search API using .NET
          Microsoft Bing MAP using Javascript

          1 Reply Last reply
          0
          • K KittyKit

            Hello there I've a website that allows a user to create and download a document. I first save the file in the server and then let the user download it. This works just fine. But when multiple users try to do this, they must create their own copy of the file in the server. Can somebody suggest a foolproof way of naming the file - so that everyuser downloads only their copy of the file. Many thanks in advance.

            V Offline
            V Offline
            Vimalsoft Pty Ltd
            wrote on last edited by
            #5

            To Resolve this you can have a Small Function that will check if the File Exists , if so tell the user else create the File. Let the user be in control of the naming. This will make things easier for them because they will remember the names. Just add a Control Mechanism to check if the File exists with that name, if it exist Suggest another name.

            Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

            1 Reply Last reply
            0
            • B Blue_Boy

              One of possibilities is: string uniqueFileName = Guid.NewGuid().ToString();


              I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

              K Offline
              K Offline
              KittyKit
              wrote on last edited by
              #6

              Hey Guys, Happy newyear. Just came back from the vacation and am glad to see so many replies. Many thanks for all of you. I guess I will settle down with GUID. tahnks once again, Blue_Boy.

              B 1 Reply Last reply
              0
              • K KittyKit

                Hey Guys, Happy newyear. Just came back from the vacation and am glad to see so many replies. Many thanks for all of you. I guess I will settle down with GUID. tahnks once again, Blue_Boy.

                B Offline
                B Offline
                Blue_Boy
                wrote on last edited by
                #7

                You are welcome, I'm glad to help you. Happy new year to you too. Year happy = new Year(2010); :thumbsup:


                I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups