#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2013
    Location
    Roanoke, VA
    Posts
    11
    Rep Power
    0

    Create a new folder, copy file from variable - input field


    Hi, I am trying to create a new folder from an input field. This is a work intranet, not public, website. On one page, the Administrator will put in a year for the new folder. Submit the form and it creates a new folder and copies a blank formatted database file to that folder.

    I can get it to work -without the input field. In this code, I just put in the year 1965...so the request form portion doesn't matter, but I want it too.

    Code:
    <%
    dim folderyear
    folderyear=request.form("createyear") 
    
    Const strFolder = "C:\inetpub\wwwroot\clips\1965\", strFile = "C:\inetpub\wwwroot\clips\blankdb\archives.mdb"
    Const Overwrite = True
    Dim oFSO
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    
    If Not oFSO.FolderExists(strFolder) Then
      oFSO.CreateFolder strFolder
    End If
    
    oFSO.CopyFile strFile, strFolder, Overwrite
    
    %>
    I have tried various things including these, but none are working:
    Code:
    Const strFolder = "C:\inetpub\wwwroot\clips\ & folderyear & \", strFile = "C:\inetpub\wwwroot\clips\blankdb\archives.mdb"
    Const strFolder = "('C:\inetpub\wwwroot\clips\' & folderyear & '\')", strFile = "C:\inetpub\wwwroot\clips\blankdb\archives.mdb"
    Const strFolder = "("'C:\inetpub\wwwroot\clips\'" & folderyear & "'\'")", strFile = "C:\inetpub\wwwroot\clips\blankdb\archives.mdb"
    Const strFolder = ("'C:\inetpub\wwwroot\clips\'" & folderyear & "'\'"), strFile = "C:\inetpub\wwwroot\clips\blankdb\archives.mdb"
    Const strFolder = ("'C:\inetpub\wwwroot\clips\' & folderyear & '\'"), strFile = "C:\inetpub\wwwroot\clips\blankdb\archives.mdb"
    Const strFolder = ("C:\inetpub\wwwroot\clips\" & folderyear & "\"), strFile = "C:\inetpub\wwwroot\clips\blankdb\archives.mdb"
    What stupid thing am I doing wrong? Thanks for your help.
  2. #2
  3. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,548
    Rep Power
    278
    try that
    you creating strFolder with folderyear and in this case it could not be a constant....
    and fix some error (missing ")
    Code:
    <%
    strFolder = "C:\inetpub\wwwroot\clips\"  & folderyear & " \" 
    strFile = "C:\inetpub\wwwroot\clips\blankdb\archives.mdb"
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    
    If Not oFSO.FolderExists(strFolder) Then
      oFSO.CreateFolder strFolder
    End If
    
    oFSO.CopyFile strFile, strFolder, Overwrite
    %>
    GK
    __________________________________________________ _____
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree
  4. #3
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2013
    Location
    Roanoke, VA
    Posts
    11
    Rep Power
    0
    YES...that did it. THANK YOU GK! I really appreciate that. - meb

    This is the final code that worked:

    Code:
    <%
    dim folderyear
    folderyear=request.form("createyear") 
    %> 
    <%
    strFolder = "C:\inetpub\wwwroot\BAD-newsclips\" & folderyear & "\" 
    strFile = "C:\inetpub\wwwroot\BAD-newsclips\blankdb\archives.mdb"
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    
    If Not oFSO.FolderExists(strFolder) Then
      oFSO.CreateFolder strFolder
    End If
    
    oFSO.CopyFile strFile, strFolder, Overwrite
    %>
    
    
    <%
    response.write("A new folder for ")
    response.write(request.form("createyear")) 
    %>
  6. #4
  7. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2013
    Location
    Roanoke, VA
    Posts
    11
    Rep Power
    0
    sorry...ignore that BAD-newclips part of the code....(during my testing...I created a couple of folders with spaces at the end and I can't get rid of the folders...so I renamed the folder to BAD....couldn't find a way to edit my response so here is the final code that worked.
    Code:
    <%
    dim folderyear
    folderyear=request.form("createyear") 
    %> 
    <%
    strFolder = "C:\inetpub\wwwroot\clips\" & folderyear & "\" 
    strFile = "C:\inetpub\wwwroot\clips\blankdb\archives.mdb"
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    
    If Not oFSO.FolderExists(strFolder) Then
      oFSO.CreateFolder strFolder
    End If
    
    oFSO.CopyFile strFile, strFolder, Overwrite
    %>
    
    
    <%
    
    response.write("A new folder for ")
    response.write(request.form("createyear")) 
    
    %>

Similar Threads

  1. Cannot copy or create folder?
    By coocoobird in forum ASP Development
    Replies: 7
    Last Post: November 11th, 2007, 12:05 PM
  2. ASP File COPY to map folder
    By satshivam in forum ASP Development
    Replies: 6
    Last Post: July 3rd, 2007, 03:55 PM
  3. All the sessions reset when run copy folder or file
    By noamway in forum ASP Development
    Replies: 2
    Last Post: March 9th, 2007, 04:52 PM
  4. Create Folder Based on Variable
    By PopNFresh in forum Visual Basic Programming
    Replies: 1
    Last Post: August 3rd, 2004, 01:02 AM

IMN logo majestic logo threadwatch logo seochat tools logo