GetDir() Method - dFPUG-Portal

salmonbrisketΛογισμικό & κατασκευή λογ/κού

2 Νοε 2013 (πριν από 3 χρόνια και 9 μήνες)

98 εμφανίσεις

Visual FoxPro Toolkit for .NET



GetDir() Method

Displays a dialog box that allows to select a directory. Please note that
this is not fully implemented as currently it asks the user to select a file
and then extracts the directory part from it.



This
method is only available in WinForms and not available for
ASP.NET WebForms.

[Visual

Basic]

Publ ic Shared Function GetDir() As String

Publ ic Shared Function GetDir(ByVal tcTitle As String) As String


[C#]

publ ic static string GetDir()

publ ic static string
GetDir(string tcTitle)


Example

[Visual

Basic]

Dim MyDir As String

MyDir = GetDir()

If Not Empty(MyDir) Then


'Do something

End If


[C#]

string MyDir = VFPToolkit.dialogs.GetDir();



Implementation

[Visual

Basic]

Public Shared Function GetDir() As String


Return GetDir("")

End Function


Public Shared Function GetDir(ByVal tcTitle As String) As String


'The GetDirBrowser is a class developed in VFPToolkitNET and is not a


'built in .NET Framework class


Dim db As GetDirBrowser = New GetDirBrows
er()


Return db.ShowIt(tcTitle)

End Function


Private Class GetDirBrowser


Inherits FolderNameEditor



' A special treatement for the GetDir() as it was not a built


' in as a .NET Framework class


' inherit the FolderNameEditor class


D
im fBrowser As FolderNameEditor.FolderBrowser



Public Sub New()


' contructor


' create an instance of FolderBrowser


fBrowser = New System.Windows.Forms.Design.FolderNameEditor.Fol derBrowser()


End Sub



Public Function ShowIt(ByVal textdescript
ion As String) As String


' set the Description label




fBrowser.Description = textdescription


fBrowser.ShowDialog() ' show the Windows


Return fBrowser.DirectoryPath ' return whatever path choosen


End Function


End Class


[C#]

public static string
GetDir()

{


return GetDir("");

}



public static string GetDir(string tcTitle)

{


//GetDirBrowser is not a built in .NET Framework class


//It is built in Visual FoxPro Toolkit for .NET and is available


//in the source code


GetDirBrowser gd = new GetDirB
rowser();


return gd.ShowIt(tcTitle);

}


private class GetDirBrowser : FolderNameEditor

{


// A special treatement for the GetDir() as it was not a built in


// .NET Framework class


// inherit the FolderNameEditor class


FolderNameEditor.FolderBrowser
fBrowser;



public GetDirBrowser()


{



// contructor



// create an instance of FolderBrowser



fBrowser = new
System.Windows.Forms.Design.FolderNameEdit or.Fol derBrowser();


}



public string ShowIt(string textdescription)


{



// set the Description la
bel





fBrowser.Description = textdescription;



fBrowser.ShowDialog(); // show the Windows



return fBrowser.DirectoryPath;// return whatever path choosen


}


~GetDirBrowser()


{



// destructor



fBrowser.Dispose();


}

}



Requirements

Namespace:

VFPToolkit

Class:

VFPToolkit.dialogs

Platforms:

Windows

98, Windows

NT

4.0, Windows

Millennium

Edition,
Windows

2000, Windows

XP

Home

Edition, Windows

XP

Professional,
Windows

.NET

S
erver

family

Assembly:

VFPToolkit (in VFPToolkitNET.dll)

See Also

VFPToolkit.dialogs Members

|
VFPToolkit Namespace