Alaska Software Inc. - File(a Shared Filder)
Username: Password:
AuthorTopic: File(a Shared Filder)
Jacob JohnFile(a Shared Filder)
on Wed, 01 Apr 2020 14:00:38 +0530
Hi,

I have a problem in File() function.


In the server there is a folder D:\CRMS. And the CRMS folder is
shared.

There is a folder REPORTS in D:\CRMS. ie. D:\CRMS\REPORTS

Server's IP is 192.168.1.100


From the client machine i am trying to check the existance of these
folders.

If (! File("\\192.168.1.100\CRMS","D"))  This retuens .F.
	....Create the folder
EndIf

But

If (! File("\\192.168.1.100\CRMS\REPORTS","D"))  This retuens .T.
	....Create the folder
EndIf

Why ?


When Right Click the Folder and Looking the Property from the Client
Machine, it shows as follows

While checking the Properties of CRMS folder, Type : File Folder
But in the Properties of CRMS\REPORTS, the Type : Share


Regards
Kiron
Carlos A Beling Re: File(a Shared Filder)
on Wed, 01 Apr 2020 10:33:53 -0300
Hi.
Good day.
Did you try the function FExists() or Directory()?

Fraternally
Beling

On 01/04/2020 05:30, Jacob John wrote:
> Hi,
> 
> I have a problem in File() function.
> 
> 
> In the server there is a folder D:\CRMS. And the CRMS folder is
> shared.
> 
> There is a folder REPORTS in D:\CRMS. ie. D:\CRMS\REPORTS
> 
> Server's IP is 192.168.1.100
> 
> 
>  From the client machine i am trying to check the existance of these
> folders.
> 
> If (! File("\\192.168.1.100\CRMS","D"))  This retuens .F.
> 	....Create the folder
> EndIf
> 
> But
> 
> If (! File("\\192.168.1.100\CRMS\REPORTS","D"))  This retuens .T.
> 	....Create the folder
> EndIf
> 
> Why ?
> 
> 
> When Right Click the Folder and Looking the Property from the Client
> Machine, it shows as follows
> 
> While checking the Properties of CRMS folder, Type : File Folder
> But in the Properties of CRMS\REPORTS, the Type : Share
> 
> 
> Regards
> Kiron
>
Andreas Gehrs-Pahl
Re: File(a Shared Filder)
on Thu, 02 Apr 2020 00:42:12 -0400
Kiron,

>I have a problem in File() function.

The File() function should be used only for data or index files that are 
within the Xbase++ default path. For anything else, especially with a fully 
qualified or relative path, I would recommend using the FExists() function.

In either case, there is a workaround, which often works with File() and 
FExists(), which is to add "\*" to the directory name, as in:

File("\\192.168.1.100\CRMS\*", "D")
or
FExists("\\192.168.1.100\CRMS\*", "D")

But, to check for the existence of a directory, especially on a different 
computer, the following function works much better, and doesn't need the 
trailing backslash (or asterisk):

Function Dir_Exists(cDirName)
LOCAL nRet := Get_File_Attributes(ConvToAnsiCp(cDirName))
return (iif(nRet == -1, .f., nRet[5]))

Function Get_File_Attributes(cFileName)
return (DllCall('Kernel32.dll', DLL_STDCALL, 'GetFileAttributesA', ; 
        @cFileName))

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[F]:   https://www.facebook.com/AbsoluteSoftwareLLC
Andreas Gehrs-Pahl
Re: File(a Shared Filder)
on Thu, 02 Apr 2020 01:06:40 -0400
In case you don't use only OEM character sets in your programs, use this 
instead:

Function Dir_Exists(cDirName)
LOCAL nRet := 0
   if Set(_SET_CHARSET) == CHARSET_OEM
      cDirName := ConvToAnsiCP(cDirName)
   endif
   nRet := Get_File_Attributes(cDirName)
return (iif(nRet == -1, .f., nRet[5]))

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[F]:   https://www.facebook.com/AbsoluteSoftwareLLC