--
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To post to this group, send email to mapi...@googlegroups.com.
To unsubscribe from this group, send email to mapinfo-l+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mapinfo-l?hl=en.
On Feb 1, 3:11 am, Peter Horsbøll Møller <mapinf...@horsboll-
moller.dk> wrote:
> Pretty easy if you are using Mi Pro 9.5 or later and want to use some .NET
> integration:
>
> *C#*
> namespace FILELib
> {
> public class MIController
> {
> //<summary>
> /// </summary>
> /// <param name="filePath">Folder to create</param>
> /// <returns>nthing</returns>
> public static void CreateFolder(string folderPath)
> {
> System.IO.Directory.CreateDirectory(folderPath);
> }
> }
>
> }
>
> *MapBasic*
> Declare Method CreateFolder
> Class "FILELib.MIController" Lib "FILELib.dll"
> (ByVal sFolderPath As String)
>
> Let me know if you want a compiled dll in stead of creating it yourself
>
> Peter Horsbøll Møller
> Pitney Bowes Business Insight - MapInfo
>
> 2010/1/31 888Peter777 <pe...@ellesmeregeological.com>
>
> > Dear All
> > Is it possible to create a directory from within a mapbasic program
> > Regards
> > Peter
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "MapInfo-L" group.
> > To post to this group, send email to mapi...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > mapinfo-l+...@googlegroups.com<mapinfo-l%2Bunsu...@googlegroups.com>
' declaration:
Declare Function CreateDirectory Lib "kernel32" Alias
"CreateDirectoryA" (ByVal s_pathname as String, ByVal
i_SecurityAttributes as Integer) as Integer
' vars
Dim s_path as String
Dim i_success as Integer
s_path = "C:\example\directory\path"
' create directory
i_success = CreateDirectory(s_path, 0)
if i_success = 0 Then
Note "Problem creating directory, please check that you have the
necessary rights to perform this operation or that the directory does
not already exist"
End Program
End If
AFAIK this should work fine under Vista64.
On Jan 31, 7:11 pm, Peter Horsbøll Møller <mapinf...@horsboll-
moller.dk> wrote:
> Pretty easy if you are using Mi Pro 9.5 or later and want to use some .NET
> integration:
>
> *C#*
> namespace FILELib
> {
> public class MIController
> {
> //<summary>
> /// </summary>
> /// <param name="filePath">Folder to create</param>
> /// <returns>nthing</returns>
> public static void CreateFolder(string folderPath)
> {
> System.IO.Directory.CreateDirectory(folderPath);
> }
> }
>
> }
>
> *MapBasic*
> Declare Method CreateFolder
> Class "FILELib.MIController" Lib "FILELib.dll"
> (ByVal sFolderPath As String)
>
> Let me know if you want a compiled dll in stead of creating it yourself
>
> Peter Horsbøll Møller
> Pitney Bowes Business Insight - MapInfo
>
> 2010/1/31 888Peter777 <pe...@ellesmeregeological.com>
>
> > Dear All
> > Is it possible to create a directory from within a mapbasic program
> > Regards
> > Peter
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "MapInfo-L" group.
> > To post to this group, send email to mapi...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > mapinfo-l+...@googlegroups.com<mapinfo-l%2Bunsu...@googlegroups.com>
'********************************************************************************************************
Include "c:/Tenman/testapp/Includes/Mapbasic.def"
' declaration:
Declare Function CreateDirectory Lib "kernel32" Alias
"CreateDirectoryA" (ByVal s_pathname as String, ByVal
i_SecurityAttributes as Integer) as Integer
' vars
Dim s_path as String
Dim i_success as Integer
Declare Sub CreateDir
Declare Sub Exitapp
Declare Sub Main
sub main
create menu "Directory Test" as
"Create a directory" calling CreateDir,
"Exit" calling ExitApp
alter menu bar add "Directory Test"
end sub
sub ExitApp
'end program
terminate application "dir_test.mbx"
end sub
Sub CreateDir
s_path = "C:\example\directory\path"
' create directory
i_success = CreateDirectory(s_path, 0)
if i_success = 0 Then
Note "Problem creating directory, please check that you have
the necessary rights to perform this operation or that the directory
does not already exist"
End Program
End If
End Sub
'*************************************************************************************************
The directory did create and did not previously exist. What could the
problem be?
Regards
Peter
Try changing:
s_path = "C:\example\directory\path"
to:
s_path = "C:\exampledirectory"
If you need to create an entirely new directory path, you'd have to
step over the folder path to find the lowest existing directory. Then
loop over the rest of the path, creating folders in turn. This isn't
necessary a good thing to do.
Declare Function SHCreateDirectoryEx Lib "shell32.dll" Alias
"SHCreateDirectoryExA" (ByVal hwnd as integer, Byval LPCWSTR as string,
ByVal
SecurityAttributes as Integer) As integer
dim err as integer
err = SHCreateDirectoryEx(0,"c:\test\test1\test2",0)
This will create the whole directory structure. No looping.
See also:
http://msdn.microsoft.com/en-us/library/bb762131(VS.85).aspx
Regards
Uffe Kousgaard