![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: changing directories programmatically Topic Summary: Created On: 29-Sep-2008 06:53 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
I'm using the mkdir() to create a folder under my C:\myown\xyz folder. I want to create folders and sub-folders under the xyz folder, through a script. Using mkdir(), I'm able to create a folder under xyz; however, I'm not sure how to create a folder under the folder I just created. Meaning, is there an equivalent of "cd" command (in windows) so that I can drive down to the folder and then use mkdir()?
Thanks. |
|
![]() |
|
![]() |
|
Why make life hard.
Following command will make all subdirectories: system "cmd /c mkdir c:\\temp\\a\\b\\c" |
|
![]() |
|
![]() |
|
Thanks Ron. Similarly, how do we check if a directory already exists? Can we used ckdir() with the system call?
Thanks Edited: 29-Sep-2008 at 17:49 by anant mitra |
|
![]() |
|
![]() |
|
Folloing function works for files or directories
bool fileExists_(string filename) { Stat sT sT = create filename if (null sT) return false delete sT return true } print fileExists_("c:\\temp\\b") "" |
|
![]() |
|
![]() |
|
An alternative method is to use my mkdir function which creates the entire path and traps errors returned by the mkdir system call.
http://www.smartdxl.com/filesdirs.html ------------------------- Tony Goodman Smart DXL limited www.smartdxl.com |
|
![]() |
|
![]() |
|
I tried, mkdir, create and the method given by Ron. None of them have been able to do what I want. So, I'm posting my script just to make sure I got the code right.
It helps have another set of eyes look at it. |
|
![]() |
|
![]() |
|
The doors mkDir requires you to create each folder with a command.
The system requires you to conver doors / to \\ to work. You best approache is: --look at Tonies makeDir include file or -- convert / to \\ in your string path_name or --or parse the path and make one directory at a time with the mkdir function. |
|
![]() |
|
![]() |
|
Thanks Tony. I used your makeDir() and although got a stack overflow error, I used Edwin's fix for it and it worked.
Just a little nitpick - It's created the folders under the C:. How do I create the folders under C:\My Documents? I tried prefixing my path_name with C:\My Documents, but that didn't help Thanks much! Edited: 29-Sep-2008 at 20:36 by anant mitra |
|
![]() |
|
![]() |
|
My documents is actually in a folder as follows:
C:\Documents and Settings\username\My Documents Paul |
|
![]() |
|
![]() |
|
Your problems isn't a nit with Tonies script, Because of the spaces you may have to either use quotation marks or a space character subsitution and of course you must have the correct name.
Edited: 30-Sep-2008 at 14:11 by ron lewis |
|
![]() |
|
![]() |
|
The variable path_name that I'm using contains, for example, /x/y. I'm prefixing it with C:\My Documents like this: path_name = "C:\\My Documents" path_name. I've tried path_name = "C:/My Documents" path_name as well. But, it still creates it under C:\.
How do I fix this? |
|
![]() |
|
![]() |
|
When I type "c:\My Documents" into Windows Explorer, I get an Error. I don't think that is a valid path, instead I think its just an alias to "c:\Documents and Settings\UserName\My Documents".
- Louie |
|
![]() |
|
![]() |
|
You are right. It's not a valid path. I tried another path and it worked.
Thanks All. |
|
![]() |
|
![]() |
|
Hello,
My script runs as a scheduled task every night. It should delete the existing directory ('XYZ' given in the code) and create it all over again. However, it's not happening. What's the problem here? Thanks. |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
changing directories programmatically
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.