473,569 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a file folder dynamically .

3 New Member
hello All ,

I am using the below given code to create a folder on a click event from a button.

The Folder name should be a string which i am taking it from the text box value.


now my problem is am not able to figure out how i can create a folder with the input text box value name.


<%@LANGUAGE="VB SCRIPT"%>

<%
Option Explicit
CreateFolder(Se rver.MapPath(". "+ "test"))
Dim objFso
'# CREATE FOLDER
function CreateFolder(fd irCRE)
Set objFso = CreateObject("S cripting.FileSy stemObject")
if Not objFso.FolderEx ists(fdirCRE) Then
objFso.CreateFo lder(fdirCRE)
Else
Exit function
End if
Set objFso = nothing
End function




%>
<html>
<input type="button" ID="buttonCreat eFolder" value="Create Folder" OnClick="Create Folder()" />

</html>
Jan 9 '08 #1
3 9134
Nicodemas
164 Recognized Expert New Member
OnClick is not a feature of VBScript. Maybe for a ASP.NET html control, but not regular ol' ASP. To get this to work, you will actually have to submit a form. Inside the form will have to be a text box. The user will have to type something into the text box, then submit the form.

ASP VBScript will then pick up the value through Request.Form.

My quick solution below is meant to be illustrative. Change the ACTION attribute on the form to the filename of your script.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. '// if the user submitted the form
  3.  
  4. if request.form("folder_name") <> "" then
  5.    ' 
  6.    ' you might want to validate folder name is legal
  7.    ' by Operating System standards...
  8.    '
  9.    set objFSO = server.createobject("scripting.filesystemobject")
  10.    folderName = request.form("folder_name")
  11.    absFolderPath = server.mappath("/") & "/" & folderName
  12.  
  13.    if not objFSO.FolderExists(absFolderPath) then
  14.       objFSO.createfolder absFolderPath
  15.    end if
  16. %>
  17.  
  18. <html>
  19.    <body>
  20.       <form method="post">
  21.          <input type="text" name="folder_name" />
  22.       </form>
  23.    </body>
  24. </html>
  25.  
Jan 9 '08 #2
sumit dureja
1 New Member
public void Createnewfolder ()
{
string str = Session["UrlUserId"].ToString();


DirectoryInfo dir = null;

dir = new DirectoryInfo(S erver.MapPath(" ~/Profile") + "/" + str);

if (!dir.Exists)
{

dir.Create();
}

}
Jan 15 '08 #3
sprabu123
1 New Member
public void Createnewfolder ()
{
string str = Session["UrlUserId"].ToString();


DirectoryInfo dir = null;

dir = new DirectoryInfo(S erver.MapPath(" ~/Profile") + "/" + str);

if (!dir.Exists)
{

dir.Create();
}

}

sir this is worknig fine. but i want give a foldername in textbox that name should be given for the folder.afetr that all folder name display in dropdown list. i select the folder name in dropdown list and upload the file for particular folder.pl send code to me.
Mar 14 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
3500
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET) template. Briefly -------------------------------------------------------------------------------------------- I need to create dynamically some...
5
11024
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been created in the wrong folder on the hard drive. Before I discovered these files, .NET kept trying to create a new project with _1 following the project...
11
9570
by: sur | last post by:
Hello, My problem is that File.Exists works fine if my file is on my local drive but returns false if its on any other drive. I think that the issue is probably file permissions and so I have tried the following: FileIOPermision permFileIO = new FileIOPermission(FileIOPermissionAccess.Read, filepath.Value.ToString());
10
1504
by: Shapper | last post by:
Hello, I am working on an ASP.NET / VB web site and I need to have 2 versions: In English and French. I could create two versions of the web site by duplicating all the pages. Is that the right way? All my contents come from a database so I can duplicate the the fields so I can have 2 language content.
4
4396
by: I_AM_DON_AND_YOU? | last post by:
There is one more problem I am facing but didn't get the solution. In my Setup Program I am not been able to create 2 things (when the program is intalled on the client machine ) : (1) create shortcut to my program/utility (2) Entry in Windows' Start --> Program Menu. Actually in my VB.Net solution I have two projects (1) MYPROGRAM (2)...
2
568
by: Eric Falsken | last post by:
Eric Falsken <eric@db4o.com> wrote on 04 Dec 2005: > craigkenisston@hotmail.com wrote on 19 Nov 2005: > >> I'm working in the migration of an asp.net application in 1.1 to 2.0. >> I'm new to this application, just worked with that some days. >> Today, I decided to open the project in VS.2005 and everything seemed >> to be fine, all opened...
8
2563
by: Paw | last post by:
Greetings. I use asp. what I need is is when a visitor comes to the site, I need it to check the host name. if "www.hometowndigest.com" is the host, then check a folder named "something" and if the folder does not exsist, create folder "www" and then copy folder "temp" and its contents. If the folder "www" is there, look in it, check to...
8
20337
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1: Start with original thumbnails & two empty sub directories STEP 2: Create smaller versions of the originals for one sub directory STEP 3: Create...
0
1121
by: vibsapril | last post by:
I have an application like blog system where I have to provide the space for every new blog. I have seen on aeonity.com that when a new blog is created, a new virtual folder is created dynamically. I am looking for the same thing but unable to implement this. Please help me to provide c# Asp.net source code so that it may create a virtual...
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.