Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

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

Results 1 to 4 of 4
Share This Thread →
  1. #1
    ecorf is offline Registered User
    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
    gk53's Avatar
    gk53 is offline Contributing User
    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,538
    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

  3. #3
    ecorf is offline Registered User
    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")) 
    %>

  4. #4
    ecorf is offline Registered User
    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")) 
    
    %>

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

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

ASP Free Advertisers and Affiliates