Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find a filename with extension dwg in a server that has a few shared folders

Status
Not open for further replies.

titoneon

MIS
Dec 11, 2009
335
US
Hi,
Let me explain my situation here, so maybe you can point me to use the right command to be executed to find what i want of course this is going to need some codes but i am not asking for code but maybe the right command that i should use and other suggestion to follow that command, i was checking for Adir() and getfile() but i don't get it right so i don't know if i am in the right track

I have a server named "CAD_SERVER", on this, there are several shared folders (ie.. Drawings, Drawings_2, Drawings_3 and so on) and of course in each of these shared folders are other folders named by numbers like
110156-110190, this mean that we can find in this previous folder i mentioned files with "dwg" extension that are in the range of 110156-110190 all of these shared folders are mapped in each workstation using a respective drive letter, for example if a user need to find filename=110158.dwg, he manually needs to go to each of his mapped drive(as the one i mentioned above) and search visually for a folder starting with the number or range number where his file could be, of course if we use the windows search command first is going to take longer to find and second if the file number is not the same as the folder name even if the filename should be inside that folder it will never find it, so what should be the approach by entering a filename and search the folder that can contain it and from there open the folder and from there of course i can visually just open the filename i want and i will be able to display/view it.
Any suggestion is very welcome
Thanks
 
You probably want to get familiar with the VFP ADIR() function.

By using the Option flags (or not) you can search for Filenames and/or Directories in a given entered directory.

You could nest FOR/ENDFOR loops testing Directory names and/or Filenames found by the ADIR() function to see if the one you are looking for is present.

Then, when found (or not), interact with the user however you need.

Good Luck,
JRB-Bldr



 
Add the file names to a database. As you say the windows search is not very helpful for that case, but once you have all paths and files in a dbf - not the files themselves, just the paths and names - searching can use SQL where clause or whatever you like.

The disadvantage is, this doesn't update automatically, when new files are added or old ones deleted. But there is no reason to not put this data about the files into one or more DBFs, you also put very abstract data for real worlds objects or persons into dbfs and that also works by maintaining the data, doesn't it?

Once you have such a database, it wouldn't even matter, if files where put inside folders with number ranges, those could merely become meta data about the images.

Bye, Olaf.
 
I agree with Olaf...

Knowing what the files are named and where the files are stored AHEAD OF TIME is the best approach.

Having to Search for where the file MIGHT BE is not a good approach.

If you already have a lot of files put SOMEWHERE and need to now allow users to access them, use the ADIR() approach or GETFILE() to programatically Find or enable users to interactively Find the files and them save that information away in a data table for future reference.

Good Luck,
JRB-Bldr


 
The way you describe it, a particular DWG file should be in ONE of the folders, although there is a possibility that it may be in several of the mapped drives.

Code:
For each of your mapped drives:
  Use ADIR() or parse a DOS/CMD DIR /b/ad command to get a list of correctly named folders (put them in a table)
  Parse out the folder names for the minimum/maximum drawing numbers
  Locate the folder name that is between( yourdrawingnumber, min, max)
  Use FILE() to check for the existence of yourdrawingnumber.dwg in that folder
  If it exists, save the full name to a results table
Next mapped drive

This assumes that:
* no file is incorrectly placed
* the folders are not nested




 
Hi everyone,
I have been working on what you guys suggested and came out with something that is working,
i an using the "Filer" but i having a little problem, i am using a form that someone already created by using "Define Class Form1 As Form" and so on, all this code i have is into a prg file, also inside this prg file as part of the code i have this.

Procedure cmdSearch.Click
Local lcFile, lcFolder

lcFile = Alltrim(Thisform.txtFile.Value)
* Validate file
If Empty(m.lcFile)
Messagebox('Please type the file to be searched first!',0+64,'Oppppppssss!')
Thisform.txtFile.SetFocus
Return(.F.)
Endif

lcFolder = Alltrim(Thisform.txtFolder.Value)
* Validate folder
If Empty(m.lcFolder)
Messagebox('Please Select the folder to be searched first!',0+64,'Oppppppssss!')
Thisform.txtFolder.SetFocus
Return(.F.)
Endif

**** Here is the loop, GetWordCount() and GetWordNum()
lnPaths = Getwordcount(m.lcFolder,';')
Zap In junk
For lnCtr = 1 To m.lnPaths
lcPath = Getwordnum(m.lcFolder,m.lnCtr,';')
Wait Window 'Working on '+m.lcPath+'......' Nowait
Thisform.SearchMe(m.lcPath, m.lcFile)
Next
****

Wait Clear
Go Top
Thisform.grid1.Refresh
Endproc

Procedure SearchMe
Lparameters lcPath, lcFile
* start Searching
Local loFiler As Filer.fileutil, lnloop, lnCtr, lcPath, lnPaths
loFiler = Createobject('filer.fileutil')
With loFiler
.SearchPath = m.lcPath
.Subfolder = Thisform.chkSub.Value
.FileExpression = m.lcFile
.Find(0)
For lnloop=1 To .Files.Count
lcFile = Addbs(.Files(m.lnloop).Path)+.Files(m.lnloop).Name
Insert Into junk Values (m.lcFile)
Endfor
Endwith
loFiler = .Null.
Endproc
Enddefine

i created a project and an exe file all of this resides in a folder in my machine and also added the runtime vfp 9.0 library and the filer.dll in the same folder and it run ok in my machine, as well when i run it from visual foxpro, now i copied that folder to another computer and when i run the exe i am getting this Error "Class definition FILER.FILEUTIL is not found." can you guys point me to the right direction here Please ? Thanks
 
The Filer.dll has a COM Server in it, you must register it with regsrv32.exe or via making a setup with installshield and using it's capabilities to register a DLL while it installs. Two warnings about Vistaa and later: 1. there is a 64bit and a 32bit regsrv32.exe and in 64bit system the 32bit one is in SysWOW64, in 32bit systems, it's in System32. also since Vista you need elevated rights to make regsrv32.exe work, so first start cmd.exe as Administrator via right click on it an "Run as Administrator" context menu item. The cmd.exe "Dos" Window will have "Administrator" in the title bar, if you do it right. If not, all you call is not elevated, even if you're logged in as Administrator.

ADIR() has all you need, so you don't need Filer and keeps you from this struggle with registering a DLL.

Bye, Olaf.
 
i am using a form that someone already created...

If you get it working, fine.

But there is a danger in that situation.
If you encounter a problem, since you did not create the Form yourself, you will have to spend time investigating and figuring out what went wrong.
And/or if something does not work the way you want it to, you will have to figure out how to code around it.

In the end it could wind up taking you MORE time to use someone else's work than to do it yourself from the start.

Good Luck,
JRB-Bldr

 
HI Olaf, JRB-Bldr
Olaf, Yes i did that, i registered on the computer that it was not working and now is working, anyway the advise about vista and later is very appreciated.
JRB-Bldr, Yes you are correct but that was some samples i found and i tried to speed up the typing, i was not aware of the filer.dll needed to be registered.

Thanks to both of you
Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top