finding subfolder of a folder getting by getFolder method in asp - asp-classic

i am troubling from this problem , i want to find the list of folder but there is some problem , i have a support folder in root directory, first i have the subfolder of this "Support" folder then in each folder i have to find a specific say "x" folder and then in this x folder i want to check each file and folder. i am sending here code . please help me ....
dim fs, fso, fo, s, x, f, filePath, a, sfPath
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder(Server.MapPath("support/"))
a = Split(pSku,"-",-1)
for each x in fo.SubFolders
sfPath= "support/" + x.Name + "/" + a(0) + "/"
//a(0) contains a folder name
set s = fs.GetFolder(server.MapPath(sfPath))
set s = nothing
next
Please tell me solution ..

You would need to use recursion if I understand your problem correctly, if you want to scan every sub file/folder of a particular folder.
Create a function, then have the function call itself on each folder it finds.

Related

Moving files between folders when folder names match partially (in R or VBA)

I'm trying to solve the following problem
I have 9 folders titled PROS_2010 to PROS_2019. Each of them has about 500 subfolders with names structured as follows e.g. PROS_201001211_FIRM NAME_number. Each subfolder has a variety of pdf files with different names.
I have created in VBA another folder called sample with about 400 subfolders, each of which is named a specific FIRM NAME. For this I used the following code:
Sub MakeFolders()
Dim Rng As Range
Dim maxRows, maxCols, r, c As Integer
Set Rng = Selection
maxRows = Rng.Rows.Count
maxCols = Rng.Columns.Count
For c = 1 To maxCols
r = 1
Do While r <= maxRows
If Len(Dir(ActiveWorkbook.Path & "\" & Rng(r, c), vbDirectory)) = 0 Then
MkDir (ActiveWorkbook.Path & "\" & Rng(r, c))
On Error Resume Next
End If
r = r + 1
Loop
Next c
End Sub
I now want to move all the pdf files that are in the original subfolders PROS_201001211_FIRM NAME_number to the folders titled FIRM NAME only.
Basically, each original subfolder contains a report about a firm for a specific year (2010 to 2019) and I want to get all the firm reports for all years in a single folder titled FIRM NAME
To make it easier I already have an excel file that basically has the complete list of subfolders that looks like this:
Data structure: Company name is the name of the folder in which I want to move the files that are currently in "attachment folder". attachment1 is the pdf file name (which always changes so ideally the code would pluck all the files in attachment folder and move them to the file with company name
Thanks in advance,
Simon
OK
So thanks to the help of a mate I found it is super easy to solve this problem using the "command" command in windows
Basically create a text file (in notepad) that has the following structure
move "original pdf file directory" "new pdf file location\"
...
Repeat the structure for each file (which requires some basic excel string manipulations)
Then save the .txt file as a .cmd file and open it.
Done

Finding Test set and Sub folder from a parent folder in QC Test Lab

I am trying to extract sub folders (not all children folders) along with Test sets(not all children test sets, only next test set) from a parent folder in QC test Lab.
Let suppose There are 2 sub folders and 1 test set in a Parent folder in QC:
-Parent Folder1
- Sub folder1
- Sub folder2
- Test Set
Using the below code i am able to extract the subfolders only not test sets:
Code:
Set TsetMgr = UserForm9.QCConnection.TestSetTreeManager 'object required
Set Root1p = TsetMgr.Root 'connect to Root
Set SubNodesRoot = Root1p.SubNodes() 'Using SubNodes method to extract SubNodes from QC
For rp = 1 To SubNodesRoot.Count 'Total SubNodes available
c1p = SubNodesRoot.Item(rp)' Finding SubNodes
MsgBox(c1p) ' SubFolder1 and Subfolder2 values are displayed.
Next
My only problem now is, i am not able to extract Test Sets along with subfolders from a parent folder.
Can anyone please help me fix this. Thanks.
I don't think there is a way to get both folders and test sets with calling one function. But you can get the folders with the method you described. And you can get the immediate child-test-sets of a TestSetFolder via the TestSetFactory of this folder:
test_set_factory = lab_folder.TestSetFactory
test_sets = test_set_factory.NewList("")
test_sets.each do |test_set|
puts "Test Set: #{test_set.Name}"
end
That should print you the names of all TestSets in the lab_folder. I think you cannot have TestSets directly in your root folder, so you can use the TestSetFactory only on sub folders.

Save an image to outside the directory in asp.net

I am trying to save an image to server.Server directory structure is as follows
httpdocs-
Folder-
Page.aspx
and
httpdocs-
Images-
Subimages
The Folder and Images are under the httpdocs. I need to save the image to subimages folder from pages.aspx. Saving image code is on pages.aspx.
I tried
string CroppedImagePath = Server.MapPath("~/Images/Subimages"+file)
But not get the exact result
Unless file contains a leading / character, that's going to end up saving as something like:
~/Images/Subimagesfilename.ext
Use Path.Combine() to build a path name. Something like this:
var CroppedImagePath = Path.Combine(Server.MapPath("~/Images/Subimages"), file);
try this
string CroppedImagePath = Server.MapPath("~/Images/Subimages/"+file)
/ after Subimages

How to find a file path in current java directory

I have a function that gets a file path as an input. input file is located in a folder in my project (etc/xsd/template.xsd). how can i set this path?
this ia my function:
JAXBUtilityTool tool = new JAXBUtilityTool("etc/xsd/template.xsd","src.com.classes");
and it can not find the file "etc/xsd/template.xsd"
System.getProperty("user.dir") does not help since when I add the rest of path to it:
System.getProperty("user.dir")+ "etc/xsd/template.xsd"
result is c:\eclipse\myworkingdirectory\project/etc/xsd/template.xsd
Try:
String path = System.getProperty("user.dir");
path = path.replaceAll("\\","/") + "/etc/xsd/template.xsd"
Source:
String.replaceAll single backslashes with double backslashes

Add file at root of zip file using DotNetZip with classic ASP

I have DotNetZip installed and running fine on a Windows 2008 server.
Using a classic ASP page, I want to bundle a bunch of comma-delimited files to a user and send it over in a zip file.
The following code works fine but it stores all the path information so the files inside the zip file are located in some ridiculous directory like C:\Inetpub\wwwroot\appname\_temp\
I'm using the following code:
Set objZip = CreateObject("Ionic.Zip.ZipFile")
sFileArray = Split(sFileArray, "|")
For iCount = 0 To UBound(sFileArray)
If sFileArray(iCount) <> "" Then
objZip.AddFile sFileArray(iCount)
End If
Next
objZip.Name = sFilePath & "test.zip"
objZip.Save()
objZip.Dispose()
Set objZip = Nothing
I see that the AddFile method allows you to specify where you want the added file to reside in the zip file if you add a second parameter. According to the documentation objZip.AddFile sFileArray(iCount), "" should put the file in the root of the zip file.
However, when I add that parameter, I get the following error:
Wrong number of arguments or invalid property assignment: 'objZip.AddFile'
Anyone have any idea what I'm doing wrong?
Thanks.
I think you are misinterperting the documentation. If the second parameter is null then the directory path of the file being added is used. If the second parameter is an empty string "" then the file is added to the root level in the zip. A quick look into the Ioniz.zip.dll shows that the single parameter override of AddFile method simply calls the the double parameter override with the second parameter set to null.
Hence your add file should look like:
objZip.AddFile sFileArray(iCount), ""
to get the result you are after.

Resources