473,386 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

MKDIR In VB ??

Hi All,

When i run below code It's not creating folder.... In can see it in msgbox prompt it showing correctly .. Could you pls help me where iam wrong....

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim str As String
  3. ftp_Date = Format(Date, "yyyymmdd")
  4. str = "D:\Daily FXPCA Trade Report\" & ftp_Date
  5. MsgBox str
  6. MkDir str
  7.  
May 18 '09 #1
6 7828
ChipR
1,287 Expert 1GB
I've used this successfully:
Expand|Select|Wrap|Line Numbers
  1. Dim fso As Object
  2. Dim str As String
  3. str = ...
  4. Set fso = CreateObject("Scripting.FileSystemObject")
  5. If Not fso.FolderExists(str) Then
  6.   fso.CreateFolder(str)
  7. End If
May 18 '09 #2
NeoPa
32,556 Expert Mod 16PB
It doesn't seem too wrong to me :S

Can you check that the string is all spelt correctly (no typos) and that the parent folder exists already. Lastly, check the permissions of the parent folder (Can you create such a subfolder manually?).
May 18 '09 #3
ADezii
8,834 Expert 8TB
This appears to be a case where you may wish to incorporate a simple Error Trap into the coding, to more clearly indicate any Errors which may occur, as in:
Expand|Select|Wrap|Line Numbers
  1. On Error GoTo Err_FolderCreation
  2. Dim str As String
  3. Dim ftp_Date As Variant
  4. Const conPATH_FILE_ACCESS_ERROR = 75
  5.  
  6. ftp_Date = Format(Date, "yyyymmdd")
  7. str = "D:\Daily FXPCA Trade Report\" & ftp_Date
  8.  
  9. MkDir str
  10.  
  11. MsgBox "The following Path, " & str & ", has successfully been created!", _
  12.         vbInformation, "Path Created"
  13.  
  14. Exit_FolderCreation:
  15.   Exit Sub
  16.  
  17. Err_FolderCreation:
  18.   If Err.Number = conPATH_FILE_ACCESS_ERROR Then     'The Folder already exists/Network Error
  19.     MsgBox "The following Path, " & str & ", already exists or there was an Error " & _
  20.            "accessing it!", vbExclamation, "Path/File Access Error"
  21.   Else
  22.     MsgBox Err.Description, vbExclamation, "Error Creating " & str
  23.   End If
  24.     Resume Exit_FolderCreation
May 19 '09 #4
Thanks ADeZii,

It worked

Thanks a lot....
May 19 '09 #5
NeoPa
32,556 Expert Mod 16PB
Perhaps you could tell us what you found the problem to be in the end?
May 19 '09 #6
ADezii
8,834 Expert 8TB
@harshakusam
You are quite welcome. I'll repeat what NeoPa has already asked, what exactly was the problem?
May 19 '09 #7

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

Similar topics

2
by: Salmo Bytes | last post by:
I have a script that wants to mirror a directory structure, reading from location1 and writing (mkdir) at location2. This code works fine on a my own desktop test box. But fails at 'mkdir' when...
2
by: Shaun | last post by:
Hello! I can't seem to get paths and variables working together: import os a = 'books' os.chdir( '/test') os.mkdir("/test/"a) the last line does not seem to work. os.mkdir(a) makes the...
7
by: DataSmash | last post by:
Hello, I think I've tried everything now and can't figure out how to do it. I want to read in a text list from the current directory, and for each line in the list, make a system directory for...
8
by: Sue | last post by:
AccessXP in Access2000 Mode: In my code I use the MkDir method to create a folder and then I want to use the transfertext method to create a delimited text file in that folder. MkDir runs and...
5
by: eoindeb | last post by:
I am trying to create a directory on Solaris using the mkdir() function. This works fine when I pass a string literal ("/etc/hosts") to mkdir, but if I try passing a directory pointer to mkdir, it...
30
by: MikeC | last post by:
Good People, I'm writing a backup utility that uses a chdir() to go into the source directory (in which the files reside that I want to back up), so I don't want to use chdir() to get into the...
8
by: vj | last post by:
How do I do the following unix command: mkdir -m770 test with the os.mkdir command. Using os.mkdir(mode=0770) ends with the incorrect permissions. Thanks, VJ
3
by: Cris | last post by:
OK, I do this call on a linux system: if(!file_exists("../pages/".$_POST."/")) { $dirname = "/home/u2/sss/sss/html/pages/".$_POST.""; mkdir($dirname, $mode); } and get this:
4
by: John | last post by:
Hi The following does not create a directory neither does it give any error message. Any ideas? $umask=umask(0); $where="/var/www/vhosts/example.com/httpdocs/friday/"; mkdir ($where,0777);...
2
by: _q_u_a_m_i_s's | last post by:
Hy, i encountered a weird problem on a server running php5, and apache. Seems like i cannot create folders that end with "/". for example: mkdir("test/") will fail mkdir("test") will work Is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
jinu1996
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...

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.