Hi all
I hope the following might be useful (I apologise if this is "old hat" for some of you). I wanted to create C:\Folder1\Folder2 when Folder1 does not exist.
It is possible to do this using MKDIR but the created folders are in lowercase.
You cannot do this with the CreateDirectory API, nor with Scripting.FileSystemObject.
Here is the solution:
Function MDEx(tcFolder) * tcFolder must be a full path including drive letter DECLARE INTEGER SHCreateDirectory In Shell32 INTEGER hwnd, STRING Path Local nResult * Path must be UNICODE nResult = SHCreateDirectory(0, StrConv(tcFolder,5)) Return nResult && 0 = Success
Possible error codes are: ERROR_BAD_PATHNAME (161) : tcFolder was a relative path ERROR_FILENAME_EXCED_RANGE (206) : Path too long ERROR_FILE_EXISTS (80) or ERROR_ALREADY_EXISTS (183) : The directory already exists ERROR_CANCELLED (1223) : Cancelled by user
Paul Newton
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
I did this:
MKDIR test1\test2
And VFP happily created both folders. I tried from both the root of C as well as starting from a sub-folder.
--
rk
From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Paul Newton Sent: Tuesday, May 31, 2022 11:32 AM To: profoxtech@leafe.com Subject: A better way to create directories?
Hi all
I hope the following might be useful (I apologise if this is "old hat" for some of you). I wanted to create C:\Folder1\Folder2 when Folder1 does not exist.
It is possible to do this using MKDIR but the created folders are in lowercase.
You cannot do this with the CreateDirectory API, nor with Scripting.FileSystemObject.
Here is the solution:
Function MDEx(tcFolder) * tcFolder must be a full path including drive letter DECLARE INTEGER SHCreateDirectory In Shell32 INTEGER hwnd, STRING Path Local nResult * Path must be UNICODE nResult = SHCreateDirectory(0, StrConv(tcFolder,5)) Return nResult && 0 = Success
Possible error codes are: ERROR_BAD_PATHNAME (161) : tcFolder was a relative path ERROR_FILENAME_EXCED_RANGE (206) : Path too long ERROR_FILE_EXISTS (80) or ERROR_ALREADY_EXISTS (183) : The directory already exists ERROR_CANCELLED (1223) : Cancelled by user
Paul Newton
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
_______________________________________________ Post Messages to: mailto:ProFox@leafe.com Subscription Maintenance: https://protect-us.mimecast.com/s/BORNCJ6Y2NhgOxqHv1EQy?domain=mail.leafe.co... OT-free version of this list: https://protect-us.mimecast.com/s/h0WJCKrY2LTZKL2FGKI8y?domain=mail.leafe.co... Searchable Archive: https://protect-us.mimecast.com/s/V1YCCL9Y2vSlqLRFr_4aC?domain=leafe.com This message: https://protect-us.mimecast.com/s/klEPCM8E2JuvPjqfPUxgB?domain=leafe.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Yes, but they are always lowercase as I pointed out
Get Outlook for Androidhttps://aka.ms/AAb9ysg ________________________________ From: ProfoxTech profoxtech-bounces@leafe.com on behalf of Richard Kaye rkaye@invaluable.com Sent: Tuesday, May 31, 2022 4:41:12 PM To: profoxtech@leafe.com profoxtech@leafe.com Subject: RE: A better way to create directories?
I did this:
MKDIR test1\test2
And VFP happily created both folders. I tried from both the root of C as well as starting from a sub-folder.
--
rk
From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Paul Newton Sent: Tuesday, May 31, 2022 11:32 AM To: profoxtech@leafe.com Subject: A better way to create directories?
Hi all
I hope the following might be useful (I apologise if this is "old hat" for some of you). I wanted to create C:\Folder1\Folder2 when Folder1 does not exist.
It is possible to do this using MKDIR but the created folders are in lowercase.
You cannot do this with the CreateDirectory API, nor with Scripting.FileSystemObject.
Here is the solution:
Function MDEx(tcFolder) * tcFolder must be a full path including drive letter DECLARE INTEGER SHCreateDirectory In Shell32 INTEGER hwnd, STRING Path Local nResult * Path must be UNICODE nResult = SHCreateDirectory(0, StrConv(tcFolder,5)) Return nResult && 0 = Success
Possible error codes are: ERROR_BAD_PATHNAME (161) : tcFolder was a relative path ERROR_FILENAME_EXCED_RANGE (206) : Path too long ERROR_FILE_EXISTS (80) or ERROR_ALREADY_EXISTS (183) : The directory already exists ERROR_CANCELLED (1223) : Cancelled by user
Paul Newton
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
[excessive quoting removed by server]
Ah. Trying to preserve case in file systems. One of my pet peeves… 😊 Definitely need to use Win API calls to do that.
Move along. Nothing to see here...
--
rk
From: ProfoxTech profoxtech-bounces@leafe.com On Behalf Of Paul Newton Sent: Tuesday, May 31, 2022 11:45 AM To: profoxtech@leafe.com Subject: Re: A better way to create directories?
Yes, but they are always lowercase as I pointed out
Get Outlook for Androidhttps://protect-us.mimecast.com/s/Pv_8CPNM9zIJgqlCrbBVL?domain=aka.ms ________________________________ From: ProfoxTech mailto:profoxtech-bounces@leafe.com on behalf of Richard Kaye mailto:rkaye@invaluable.com Sent: Tuesday, May 31, 2022 4:41:12 PM To: mailto:profoxtech@leafe.com mailto:profoxtech@leafe.com Subject: RE: A better way to create directories?
I did this:
MKDIR test1\test2
And VFP happily created both folders. I tried from both the root of C as well as starting from a sub-folder.
--
rk
From: ProfoxTech mailto:profoxtech-bounces@leafe.com On Behalf Of Paul Newton Sent: Tuesday, May 31, 2022 11:32 AM To: mailto:profoxtech@leafe.com Subject: A better way to create directories?
Hi all
I hope the following might be useful (I apologise if this is "old hat" for some of you). I wanted to create C:\Folder1\Folder2 when Folder1 does not exist.
It is possible to do this using MKDIR but the created folders are in lowercase.
You cannot do this with the CreateDirectory API, nor with Scripting.FileSystemObject.
Here is the solution:
Function MDEx(tcFolder) * tcFolder must be a full path including drive letter DECLARE INTEGER SHCreateDirectory In Shell32 INTEGER hwnd, STRING Path Local nResult * Path must be UNICODE nResult = SHCreateDirectory(0, StrConv(tcFolder,5)) Return nResult && 0 = Success
Possible error codes are: ERROR_BAD_PATHNAME (161) : tcFolder was a relative path ERROR_FILENAME_EXCED_RANGE (206) : Path too long ERROR_FILE_EXISTS (80) or ERROR_ALREADY_EXISTS (183) : The directory already exists ERROR_CANCELLED (1223) : Cancelled by user
Paul Newton
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
[excessive quoting removed by server]
_______________________________________________ Post Messages to: mailto:ProFox@leafe.com Subscription Maintenance: https://protect-us.mimecast.com/s/_eLcCQWN26HJVmxC9U2D1?domain=mail.leafe.co... OT-free version of this list: https://protect-us.mimecast.com/s/GnYBCR6M0PhyY8VC05sj0?domain=mail.leafe.co... Searchable Archive: https://protect-us.mimecast.com/s/EKstCVO5k7szB1virRa4m?domain=leafe.com This message: https://protect-us.mimecast.com/s/9R0jCW6wlQhN3vkcB8KEm?domain=leafe.com ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Dne 31.5.2022 v 17:32 Paul Newton napsal(a):
Hi all
I hope the following might be useful (I apologise if this is "old hat" for some of you). I wanted to create C:\Folder1\Folder2 when Folder1 does not exist.
fso = createobject('Scripting.FileSystemObject') fldr = fso.CreateFolder('C:\MyTest')
It is possible to do this using MKDIR but the created folders are in lowercase.
You cannot do this with the CreateDirectory API, nor with Scripting.FileSystemObject.
Here is the solution:
Function MDEx(tcFolder)
- tcFolder must be a full path including drive letter
DECLARE INTEGER SHCreateDirectory In Shell32 INTEGER hwnd, STRING Path Local nResult
- Path must be UNICODE
nResult = SHCreateDirectory(0, StrConv(tcFolder,5)) Return nResult && 0 = Success
Possible error codes are: ERROR_BAD_PATHNAME (161) : tcFolder was a relative path ERROR_FILENAME_EXCED_RANGE (206) : Path too long ERROR_FILE_EXISTS (80) or ERROR_ALREADY_EXISTS (183) : The directory already exists ERROR_CANCELLED (1223) : Cancelled by user
Paul Newton
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
On 31-May-22 4:32 PM, Paul Newton wrote:
Hi all
I hope the following might be useful (I apologise if this is "old hat" for some of you). I wanted to create C:\Folder1\Folder2 when Folder1 does not exist.
It is possible to do this using MKDIR but the created folders are in lowercase.
You cannot do this with the CreateDirectory API, nor with Scripting.FileSystemObject.
....
MKDIR "C:\Temp\XyZ"
Nope! - I had a C:\Temp dir already and it created C:\Temp\XyZ - I also tried MKDIR "C:\TempXyZ" and that also worked.
Win10 64 bit
On 31-May-22 11:17 PM, Paul Newton wrote:
Andy
On my system
MkDir "C:\Test1\Test2"
Creates the folders in lowercase (test1 and test2). Any ideas?
Paul
On 31/05/2022 23:07, AndyHC wrote:
MKDIR "C:\Temp\XyZ"
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
Same here - Win10 64 bit
On 31/05/2022 23:41, AndyHC wrote:
Nope! - I had a C:\Temp dir already and it created C:\Temp\XyZ - I also tried MKDIR "C:\TempXyZ" and that also worked.
Win10 64 bit
On 31-May-22 11:17 PM, Paul Newton wrote:
Andy
On my system
MkDir "C:\Test1\Test2"
Creates the folders in lowercase (test1 and test2). Any ideas?
Paul
On 31/05/2022 23:07, AndyHC wrote:
MKDIR "C:\Temp\XyZ"
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
Creating director one folder at a time gives the results you desire.
e.g. Following gives desired results.
mkd("C:\tES\xyZ")
PROCEDURE mkd(vPath as String)
FOR n = 2 TO OCCURS("",vPath) MD(SUBSTR(vPath,1,ATC("", vPath, n))) ENDFOR
MD &vPath
ENDPROC
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Paul Newton Sent: Wednesday, 1 June 2022 8:44 AM To: profoxtech@leafe.com Subject: Re: A better way to create directories?
Same here - Win10 64 bit
On 31/05/2022 23:41, AndyHC wrote:
Nope! - I had a C:\Temp dir already and it created C:\Temp\XyZ - I also tried MKDIR "C:\TempXyZ" and that also worked.
Win10 64 bit
On 31-May-22 11:17 PM, Paul Newton wrote:
Andy
On my system
MkDir "C:\Test1\Test2"
Creates the folders in lowercase (test1 and test2). Any ideas?
Paul
On 31/05/2022 23:07, AndyHC wrote:
MKDIR "C:\Temp\XyZ"
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
Yes Darren, I am quite aware of that but I was trying to create an arbitrary number of folders and subfolders _at one fell swoop_
Paul
On 01/06/2022 00:00, Darren wrote:
Creating director one folder at a time gives the results you desire.
e.g. Following gives desired results.
mkd("C:\tES\xyZ")
PROCEDURE mkd(vPath as String)
FOR n = 2 TO OCCURS("",vPath) MD(SUBSTR(vPath,1,ATC("", vPath, n))) ENDFOR
MD &vPath
ENDPROC
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Paul Newton Sent: Wednesday, 1 June 2022 8:44 AM To:profoxtech@leafe.com Subject: Re: A better way to create directories?
Same here - Win10 64 bit
On 31/05/2022 23:41, AndyHC wrote:
Nope! - I had a C:\Temp dir already and it created C:\Temp\XyZ - I also tried MKDIR "C:\TempXyZ" and that also worked.
Win10 64 bitOn 31-May-22 11:17 PM, Paul Newton wrote:
Andy
On my system
MkDir "C:\Test1\Test2"
Creates the folders in lowercase (test1 and test2). Any ideas?
Paul
On 31/05/2022 23:07, AndyHC wrote:
MKDIR "C:\Temp\XyZ"
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]