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. How to check for duplicates before uploading.

How to check for duplicates before uploading.

Scheduled Pinned Locked Moved ASP.NET
csharphelpasp-netdatabasetutorial
6 Posts 3 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.
  • M Offline
    M Offline
    Mantaii
    wrote on last edited by
    #1

    Hi! I have a small upload site that I have built but one thing I can't work out is how to check to see if the file path has already been used. When I upload just now I create a website address which is saved in doc_url within my table. What I want to check is that when uploading a new file, there isnt already an identical url created within doc_url. If there is already a file within the database with the same path then I want to throw up an error message so the user knows there is already a file saved at this location with the same name. I'm using VS2005, C#, ASP.net Thanks for your help in advance.

    D P 2 Replies Last reply
    0
    • M Mantaii

      Hi! I have a small upload site that I have built but one thing I can't work out is how to check to see if the file path has already been used. When I upload just now I create a website address which is saved in doc_url within my table. What I want to check is that when uploading a new file, there isnt already an identical url created within doc_url. If there is already a file within the database with the same path then I want to throw up an error message so the user knows there is already a file saved at this location with the same name. I'm using VS2005, C#, ASP.net Thanks for your help in advance.

      D Offline
      D Offline
      Deshbir Singh
      wrote on last edited by
      #2

      add a random numder like doc_url_randomNumber.

      Prince Team Lead Quest Solutions www.imaginethinkact.com

      M 1 Reply Last reply
      0
      • D Deshbir Singh

        add a random numder like doc_url_randomNumber.

        Prince Team Lead Quest Solutions www.imaginethinkact.com

        M Offline
        M Offline
        Mantaii
        wrote on last edited by
        #3

        But that means there are two files the exact same within the database, what I want is to have only 1 version of the url which means, one version of the file I have uploaded. To explain a bit more, when I upload a file e.g. example.gif to a folder I automatically create a url e.g. http://localhost/folder1/example.gif Now, if I upload a file with the exact same name to the exact same folder I want a message to be displayed saying, there is already a file with this name in this folder.

        D 1 Reply Last reply
        0
        • M Mantaii

          But that means there are two files the exact same within the database, what I want is to have only 1 version of the url which means, one version of the file I have uploaded. To explain a bit more, when I upload a file e.g. example.gif to a folder I automatically create a url e.g. http://localhost/folder1/example.gif Now, if I upload a file with the exact same name to the exact same folder I want a message to be displayed saying, there is already a file with this name in this folder.

          D Offline
          D Offline
          Deshbir Singh
          wrote on last edited by
          #4

          Just loop through that folder and compare the file names with your new filename. upload only when result is "no match found".

          Prince Team Lead Quest Solutions www.imaginethinkact.com

          1 Reply Last reply
          0
          • M Mantaii

            Hi! I have a small upload site that I have built but one thing I can't work out is how to check to see if the file path has already been used. When I upload just now I create a website address which is saved in doc_url within my table. What I want to check is that when uploading a new file, there isnt already an identical url created within doc_url. If there is already a file within the database with the same path then I want to throw up an error message so the user knows there is already a file saved at this location with the same name. I'm using VS2005, C#, ASP.net Thanks for your help in advance.

            P Offline
            P Offline
            Perry Holman
            wrote on last edited by
            #5

            Very simple! You can handle that as below: string filePath = Server.MapPath("~/folder1/example.gif"); if (File.Exists(filePath)) { //show a message to the user }

            Welcome to www.softwaretree.net! You can find many excellent audio/video converter tools there!

            M 1 Reply Last reply
            0
            • P Perry Holman

              Very simple! You can handle that as below: string filePath = Server.MapPath("~/folder1/example.gif"); if (File.Exists(filePath)) { //show a message to the user }

              Welcome to www.softwaretree.net! You can find many excellent audio/video converter tools there!

              M Offline
              M Offline
              Mantaii
              wrote on last edited by
              #6

              How would I loop through a database to check all entries in a single column before submitting? Sorry if these are easy questions, still learning .Net but everything I learn gets stored in a safe place for future reference :) Thanks for your continued help!

              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