Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 How to search for a particular folder in localdisk

Author  Topic 

Mamatha
Posting Yak Master

102 Posts

Posted - 2005-01-06 : 01:54:28
Hi

I want to search for a particular folder in localdisk,actually i don;t know where it is localted.But i want to display files in that folder.How can i do this,is there any related code,i did some functionality but some times its giving errors,means it not getting the correct path.Please give me the solution,it very urgent for me.
Dim objFSO , objDrive , drive
'create an instance of FileSystemObject
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'Set objDrive = objFSO.Drives

For Each drive in objFSO.Drives
if not drive="A:" then
Set objFolder = objFSO.GetFolder(drive&"\")
'Response.Write(drive)
for each folder in objFolder.subfolders

for each folder_main in folder.subfolders

for each folder_sub in folder_main.subfolders

if folder_sub.name = "MSSQL" then


Response.Write(folder_sub)

exit for
end if
next
next
next
end if
next

Mamatha

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-01-19 : 06:39:01
Try this


create table #t (Message nvarchar(1000))

insert #t
EXEC master..xp_cmdshell 'dir c:\test'
select * from #t

if len((select * from #t where message='File not Found'))> 0
Print 'Folder Not Found'
else
Print 'Folder Found'

drop table #t

Madhivanan
Go to Top of Page
   

- Advertisement -