Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) Demonstrate Directory Path FunctionsDemonstrates the path functions GetDirectoryName, GetExtension, GetFileName, and GetFileNameWithoutExtension.
// Important: See this note about string length limitations for strings returned by sp_OAMethod calls. // CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @fac int EXEC @hr = sp_OACreate 'Chilkat_9_5_0.FileAccess', @fac OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END -- Note: Chilkat accepts either forward slash or backslash chars as directory separators.. EXEC sp_OAMethod @fac, 'GetDirectoryName', @sTmp0 OUT, '/MyDir/MySubDir/myfile.ext' PRINT @sTmp0 EXEC sp_OAMethod @fac, 'GetDirectoryName', @sTmp0 OUT, '/MyDir/MySubDir' PRINT @sTmp0 EXEC sp_OAMethod @fac, 'GetDirectoryName', @sTmp0 OUT, '/MyDir/' PRINT @sTmp0 EXEC sp_OAMethod @fac, 'GetDirectoryName', @sTmp0 OUT, '/MyDir' PRINT @sTmp0 EXEC sp_OAMethod @fac, 'GetDirectoryName', @sTmp0 OUT, '/' PRINT @sTmp0 EXEC sp_OAMethod @fac, 'GetExtension', @sTmp0 OUT, 'C:/mydir.old/myfile.ext' PRINT @sTmp0 EXEC sp_OAMethod @fac, 'GetExtension', @sTmp0 OUT, 'C:/mydir.old/' PRINT @sTmp0 EXEC sp_OAMethod @fac, 'GetFileName', @sTmp0 OUT, 'C:/mydir/myfile.ext' PRINT @sTmp0 EXEC sp_OAMethod @fac, 'GetFileName', @sTmp0 OUT, 'C:/mydir/' PRINT @sTmp0 EXEC sp_OAMethod @fac, 'GetFileNameWithoutExtension', @sTmp0 OUT, 'C:/mydir/myfile.ext' PRINT @sTmp0 EXEC sp_OAMethod @fac, 'GetFileNameWithoutExtension', @sTmp0 OUT, 'C:/mydir/' PRINT @sTmp0 PRINT '---' EXEC @hr = sp_OADestroy @fac END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.