Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem in Creating Directory
Message
De
20/11/2017 16:03:56
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01655649
Message ID:
01655734
Vues:
38
Still The same Problem persists...

It seems that there is a Problem with my File. It seems that the file has created without any extension and because of it is not permitting to create the Folder of the same name beside it. But if I give Extension to that File Manually, Folder is created Beside it.

Here is the File. You can See if you create a Folder using VFP code at the location of the file with the same name, VFP will Definitely throw an Error.

https://www.dropbox.com/s/4jj9v4knl91g7v4/Soap?dl=0





If you have a file c:\Test\Soap.txt, then you can create a folder with the same name, excluding the file extension:

lcFile = "c:\Test\Soap.txt"
lcFolder = FORCEPATH(JUSTSTEM(m.lcFile), JUSTPATH(m.lcFile)) && Get full path without file extension.
MKDIR (m.lcFolder)

>
>>Yes, at last worked....
>>
>>But Since there was File with same name of the Folder that was to be created at that same location it gave an error. So Will have to change the Name of my Folder to say FolderSoap etc. Is It so ?
>>
>>It gave error as A subdirectory of a File already Exist. If I delete the File. Folder is Created without Error.
>>
>>Thanks
>>
>>
>>
>>>You need to use name substitution:
>>>
>>>MKDIR (cFolder)
>>>
>>>
>>>>Sir,
>>>>
>>>>No, MKDIR or MD is also Not working at my End. I am not getting what mistake I am doing. I will Try to explain the problem again.
>>>>
>>>>I have a Folder. Inside that Folder I have many other folders and Inside that Many Folders I Have Many files. That is to say that I have recursive folders and Inside that Many Files.
>>>>
>>>>Using a Code I have taken the Full Path of all the Files inside these Folders in a cursor.
>>>>
>>>>So if I have a record say
>>>>"D:\Data\Green\Soaps.txt, I need to Create a Folder(i.e Directory) inside Green Folder with the Name "Soaps".
>>>>"D:\Data\Yellow\Perfumes.txt, I need to Create a Folder(i.e Directory) inside Green Folder with the Name "Perfumes"
>>>>
>>>>Now Taking 1st Record suppose I have sDirectory = "D:\Data\Green\" and OFilename="Soaps"
>>>>
>>>>Now If I use MD or MKDIR I get following results
>>>>
>>>>cFolder=sDirectory+oFilename
>>>>
>>>>MKDIR cFolder && a Folder with Name 'cFOlder' is Created inside Green Folder instead of 'Soap'
>>>>MKDIR m.cFolder && a Folder with Name 'cFOlder' is Created inside Green Folder instead of 'Soap'
>>>>MKDIR 'm.cFolder' && a Folder with Name 'cFOlder' is Created inside Green Folder instead of 'Soap'
>>>>MKDIR "m.cFolder" && a Folder with Name 'cFOlder' is Created inside Green Folder instead of 'Soap'
>>>>
>>>>MD is also giving the same result
>>>>
>>>>Regrads
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>1)sDirectory and OriginalFile must wrote with comas ["] at begin and end
>>>>>2)modern vfp dont use & go to m dot its better and avoid some errors where there is spaces in string.
>>>>>3) '&cDir" is evalued as &cDir as a string.use m.cdir
>>>>>4)comment in prg must begin with : &&Does Not Create any Directory with the Required FileName
>>>>>or * at the begin of line
>>>>>
>>>>>5) for use of CreateDirectory API can read this sample can help you : http://www.news2news.com/vfp/?example=1&function=1
>>>>>
>>>>>At the end vfp made all these exercices in one native commad:MKDIR or MD
>>>>>its also as it in msDOS command.
>>>>>very simple to use:
>>>>>
>>>>>try  &&avoid error if folder to create already exists.
>>>>>MD cPath   && or  MKDIR cPath
>>>>>catch
>>>>>messagebox("folder already exist!",16+4096,"error")
>>>>>endtry 
>>>>>
>>>>>use APIs when you dont have a vfp explicit language solution only.
>>>>>
>>>>>note: see also RMDIR to remove a folder.
Harsh
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform