473,568 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making A Folder to place a text file in Code

556 Contributor
Hi there i was wondering how you make a folder in code to place a text document. another words, i want to create a folder for a text file i create so when iim done with writing the txt file it will create a folder to store it in. But i don't know how to do this this is my code.

Create My Folder:

Expand|Select|Wrap|Line Numbers
  1. Private Sub newfolder()
  2.     'This is the folder I want to create
  3. '----------------------------------------------------------------------
  4.     Dim ofilesys As New FileSystemObject
  5.     Dim ofolder As Folder
  6.     Set ofolder = ofilesys.CreateFolder("C:\Program Files\MyDiary")
  7. End Sub
Place Folder In this But Where?

Expand|Select|Wrap|Line Numbers
  1. Private Sub SaveToLog()
  3. ' I want the created folder to be in here somewhere but WHERE!
  4. '-------------------------------------------------------------
  5. Dim ff
  6. ff = FreeFile
  7. Open "C:\MyDiary.txt" For Append As #ff
  8. Print #ff, vbNewLine; "Name" & " " & User; vbNewLine _
  9. & " " & "Subject" & "  " & Subject; vbNewLine _
  10. & " " & "Date" & "  " & DateOfEntry; vbNewLine _
  11. & " " & "Log Entry: " & "  " & Log; vbNewLine _
  12. ; vbNewLine; DiaryLog & "  " & vbNewLine; Now(); vbNewLine
  13. Close #ff
  14.     Shell "Notepad.exe C:\MyDiary.txt", vbNormalFocus
  15.     DiaryLog.Text = ""
  16.     User.Text = ""
  17.     Log.Text = ""
  18.     Subject.Text = ""
  19.     User.SetFocus
  20. End Sub
I hope this explains it all if not tell me and i will try again.

Apr 13 '09 #1
4 1619
556 Contributor
doesn't anybody know how to do this, on this site...
Apr 15 '09 #2
1,445 Recognized Expert Top Contributor

Use this code, to make folder (Code without FSO) :

Expand|Select|Wrap|Line Numbers
  1. Dim FoldName As String
  2. FoldName = "C:\MyFolder"
  3. If Trim(Dir(FoldName,vbDirectory)) ="" Then
  4.     MkDir FoldName
  5. End if
Apr 15 '09 #3
556 Contributor
ok i have put this in the code. i hope it's in the right area, but how do i put the text file in there (Folder)


Expand|Select|Wrap|Line Numbers
  1. Private Sub SaveToLog()
  2.     Dim MyDiary As String
  3.     Dim ff
  4.     ff = FreeFile
  5.         Open "C:\My Diary.txt" For Append As #ff
  6.         Print #ff, "Name" & "  " & User; vbNewLine _
  7.             & " " & "Subject" & "   " & Subject; vbNewLine _
  8.             & " " & "Date" & "   " & DateOfEntry; vbNewLine _
  9.             & " " & "Log Entry: " & "   " & Log; vbNewLine _
  10.             ; vbNewLine; DiaryLog & "   " & vbNewLine; Now(); vbNewLine
  11.         Close #ff
  12.             Shell "Notepad.exe C:\My Diary", vbNormalFocus
  13.             DiaryLog.Text = ""
  14.             User.Text = ""
  15.             Log.Text = ""
  16.             Subject.Text = ""
  17.             User.SetFocus
  19.             MyDiary = "C:\MyDiary"
  20.             If Trim(Dir(MyDiary, vbDirectory)) = "" Then
  21.                 MkDir MyDiary
  22.             End If
  23. End Sub
Apr 15 '09 #4
556 Contributor
Since there is no response i guess this isn't possible to do.

thanks anyway!!!!

Apr 16 '09 #5

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

Similar topics

by: Josh | last post by:
Currently we open a form and manualy place the pic in each new record. I need someway for to give Access a folder and then have it import each pic it finds in the folder and place the file name in the txtFilename text box. Can access do this?
by: Pavel | last post by:
Hello. I am trying to make a folder compressed and failing miserably. Below are three ways that I tried to make it compressed, all of them compile and run w/o any problems, but the folder is still not-compressed. (using NTFS, win2k) // some folder string path = @"C:\TEMP\";
by: jasonburrwc84 | last post by:
I'm new to asp.net so bare with me. I'm reading through the asp.net unleashed book and am to the section on creating classes. After creating a ..vb file which I can successfully compile and placing the .dll file in the bin directory I get the following error message: BC30002: Type 'Quote' is not defined. Adder is in the new namespace I...
by: Topper | last post by:
Hello. I have simple web folders structure: -ROOT - BIN WebService.dll WebService.asmx I need to use my WebService.dll not in bin folder - for example, in ROOT. How do i this? How can i do this without .config file only with some configuration
by: webandwe | last post by:
Hi, I got form that let you state a folder name, on sumbit thw script creates the folder with the name you stated, the problem is I want it to upload the php file "view.php" when the folder is created, I think I set the value wrong but can get it to work original script <?php #include ("mymail.php"); $folder = $_POST; ?> <?php
by: Noozer | last post by:
I'm looking for a "smart folder" program to run on my Windows XP machine. I'm not having any luck finding it and think the logic behind the program is pretty simple, but I'm not sure how I'd implement this. I've done some VB6 programming and dabbled in VS.Net. Can someone share some pointers in how I could implement the following? ...
by: alivip | last post by:
Is python provide search in parent folder contain sub folders and files for example folder name is cars and sub file is Toyota,Honda and BMW and Toyota contain file name camry and file name corola, file name honda contain folder accord and BMW contain file name X5 Is there way to enter name of parent folder(cars) and search in all sub...
by: alivip | last post by:
how to ingrate my code to read text in in parent folder contain sub folders and files for example folder name is cars and sub file is Toyota,Honda and BMW and Toyota contain file name Camry and file name corolla, file name Honda contain folder accord and BMW contain file name X5 Is there way to enter name of parent folder(cars) and search in...
by: Keith G Hicks | last post by:
I'm having a lot of trouble with "file in use" errors in my "folder watcher" project. Starting and stopping the watcher and reading my XML file work fine. Once the watcher is started, I'm reading the text files from the watched folder line by line into variables and then posting them to a SQL table. All of the code for the form is shown...
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...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
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. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
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...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
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...
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.