Dynamically saving file location - text-files

I have an asp.net app and I am trying to save a text file to a folder that changes with each client. How can I write it to save the files to a folder that changes. For example one customer might be C:\inetpub\wwwroot\site1\ another might be C:\inetpub\wwwroot\site2.
Relative paths don't seem to work, and I've tried GetCurrentDirectory but it kept giving me the wrong directory.
Thanks

You should try :
In the *.aspx.cs file :
string currentPath = Server.MapPath("~");
I don't have the tools to test here, but I think the code is right.

Take a look at Path.GetDirectoryName(Request.ServerVariables("SCRIPT_NAME")).

You should add a value to the web.config file which is set to the path where the file is saved.
Then, in you code, retrieve this value from the documentation, and use that path when saving.

Related

caffeine simulator: could not find file: WebSearch1.spc.bz2

I'm simulating in Caffeine's simulator a sequence of a several traces, of different formats.
However, when trying to run Umass storage traces I get errors, e.g.:
Could not find file: WebSearch2.spc.bz2
I guess that the problem dwells in some combination of the format, path, and filename.
E.g., when writing in the .conf file:
paths = ["lirs:loop.trace.gz"]
the format is "lirs", and indeed there's a file
\simulator\src\main\resources\com\github\benmanes\caffeine\cache\simulator\parser\lirs\loop.trace.gz
so this works fine.
Similarly, I created under \parser a sub-directory named "umass-storage", and downloaded there the file WebSearch2.spc.bz2, and then wrote in the .conf file:
paths = ["umass-storage:WebSearch2.spc.bz2"]
I tried also unzipping the file, and then use paths = ["umass-storage:WebSearch2.spc"]
as well as a few other combinations, but all of them give the error above.
To discover the trace files automatically they have to be placed in the same package as its trace reader. In this case it would be ../parser/umass/storage. However, since it is a large file you might not want to include it in you repository. Instead, you can specify the absolute path and keep the files in an external directory.
OK, thanks to Ben I solved it, and got the tiny trick here.
For most traces it's enough to write merely the format name (which is also the directory name), e.g.:
paths = ["lirs:loop.trace.gz"]
However, umass traces include 2 sub-cases (storage / network). Hence it works (at least for me) only when stating the file's full path, e.g.,
paths = ["umass-storage:/Users/ben/Documents/traces/umass/WebSearch2.spc.bz2"

UFT OTA - Get ID of copied test set folder

I have (after FOREVER) figured out how to copy a test set folder from one location to another and rename it using a explicit folder id. Now, I want to rename the new folder right after pasting, so the id will NOT be known. I have found absolutely NOTHING on how I can do this.
I'm trying my hardest to use the online resource for OTA, but it's really unhelpful unless you already know the language. I can't seem to find what I need, so please don't suggest that.
Thanks in advance. Currently very frustrated and ready to throw out my computer.
Here's what I have to copy, paste, and rename a specific node by id
Set qcConnection = QCutil.QCConnection
copiedTestSet = qcConnection.TestSetTreeManager.CopyToClipboard(3)
QCConnection.TestSetFactory.PasteFromClipboard copiedTestSet,6,2,1
Set renameTest = qcconnection.TestSetTreeManager.NodeByID(30)
print renameTest.Name
renameTest.Name = "Rename Test"
renameTest.Post
Set renameTest = Nothing
Set copiedTestSet = Nothing
You will know the folder name of the pasted folder, because it should be same as the copied folder, you can simple search for the pasted folder with name under the parent folder.
Below page have few functions which can help you
https://github.com/sumeet-kushwah/ALM_OTA_Wrapper/blob/master/ALM_Wrapper/TestLabFolders.cs
There are three functions you should search for
FindChildFolderByName
FindChildFolders
GetTestSetFolder
I was able to find what I needed using sumeet's suggestion above. My exact code is below using variables because I need to be able to run this with any folder. It runs right after the paste command above. I had to insert a wait after pasting for some reason, but it works for now. I'll trouble shoot that later
Set renameTest = qcconnection.TestSetTreeManager.NodeByPath(strPath & "\" & strEventFolder)

Specify target folder when using batch loader in Oracle Webcenter Content

I'm using Batch Loader to migrate a large number of files. I'm generating my hda file using a script on the source system. How can I specify the target folder? Everything I've migrated so far has no entry for Folder when I view it's info, and I can't find a way to specify it. Sample of my hda below.
# Batch load data for TEST_FILE_3 as jpg
Action=insert
dDocName=TEST_FILE_3_as_jpg
dDocType=Document
dDocTitle=TEST_FILE_3 as jpg title
dDocAuthor=usr_TEST_FILE_3
dSecurityGroup=Public
primaryFile=TEST_FILE_3.jpg
dInDate=01/29/2018
<<EOD>>
In Native UI, change User Profile Layout to top menus and do a search. When Item is returned, access its Info. When info is displayed, add: &IsJava=1 to the url and enter.
This shows all metadata field.s Ones you are looking for are one of these: fParentPath, fParentPathLocalized, ownerFilePath, ownerFilePathLocalized
Here are a few steps to assist you:
Place a file in the folder you want your document to end up in.
Find the document info page and append &IsJava to the url. Something like
http://.../cs/idcplg?IdcService=DOC_INFO&dID=110113&IsJava
Examine the output. You will find variables that indicate the path. Their names will differ depending on what components you are using, but a good guess is fParentPath
Copy name and value to your batch loader file

datastage parameter for file directory not working

I am creating an extract from sequential file. I created a parameter with the correct file location and when I try to "View Data", it says it can't find the file. If I hard code the location it finds the file and I am able to "View Data".
example:
#filedirectory# = aaa/bbb/ccc/
so my entry for "File" is #filedirectory#filename.txt and this does not work
however, the following does work
aaa/bbb/ccc/filename.txt
Any ideas what would cause this?
Try using the absolute path. Start with a / and the root directory.
Second point is that the parameter itself does not have "#". The "#" are only needed to reference it - in the Sequential File stage. So name it filedirectory when you define it in the job.
Recommendation:
As filedirectory will probably be used throughout your project I recommand using a ParameteSet.
I had the same issue, and it happened I forgot to include the directory parameter before the file parameter. Hope this information helps someone.

File does not begin with '%PDF-' when including image using FPDF in Classic ASP

I've been stuck on this problem for a while, done lots of searches and tried various solutions that others reported to be working, and yet I'm still stuck. So any suggestion is hugely appreciated. Please let me know if I'm being unclear. Many thanks in advance!!
I'm trying to generate a PDF in Classic ASP (I know....) with FPDF v.1.01 (available from http://www.aspxnet.it/public/Default.asp?page=172). But I keep getting a message "File does not begin with '%PDF-'" when the PDF is populated. I've tried this in Firefox 7.0.1, IE9, which are the two browsers we use at work. If I remove this line from the code, then everything works as expected. So all I know is this line is the trouble maker (maybe?)
this.Image('bg_logo_small.jpg',10,8,213,46);
I have a file named report.asp. The organization of the files looks like this:
./rpt/report.asp
./rpt/fpdf.asp
./rpt/bg_logo_small.jpg
./rpt/fpdf/ - this directory contains all the files extracted from fpdf1.01.zip
./rpt/fpdf/extends/
./rpt/fpdf/fonts/
./rpt/fpdf/includes/
./rpt/fpdf/models/
and report.asp looks like this,which is pretty much taken directly from the example on aspxnet.it site, except that I'm using my own jpg:
<%#LANGUAGE="javascript" CODEPAGE="65001"%>
<!--#include file="fpdf.asp" -->
<%
var pdf=new FPDF();
pdf.Header=function Header()
{
this.Image('bg_logo_small.jpg',10,8,213,46);
this.SetFont('Arial','B',15);
this.Cell(80);
this.Cell(30,10,'Title',1,0,'C');
this.Ln(20);
}
pdf.Footer=function Footer()
{
this.SetY(-15);
this.SetFont('Arial','I',8);
this.Cell(0,10,'Page '+ this.PageNo()+ '/{nb}',0,0,'C');
}
pdf.CreatePDF();
pdf.SetPath("fpdf/");
pdf.SetFont("Arial","",16);
pdf.Open();
pdf.AddPage();
pdf.Cell(40,10,"Hello Word!");
pdf.Close();
pdf.Output();
%>
I've tried the same thing in VBScript with
pdf.LoadModels("bgimg")
and function Header() and function Footer() placed in bgimg.mod, which was saved in
./rpt/fpdf/models/
The code above is all report.asp contains - no HTML inside.
I am not sure, if you haven't solved the problem yet, but anyway I answer, because it could help to somebody else.
I had the same problem and I was browsing and looking long long time for solution.
Finally I found the solution.
Go in fpdf.asp file, look for line with code:
xfile=Server.MapPath(lib.fso.GetTempName())
You can change the code e.g. like this:
xfile=Server.MapPath("Temp/"+lib.fso.GetTempName())
where "Temp/" is name of folder where temporary file during PDF file generation will be created and later deleted. The main trick is to assign "Modify" access rights to the folder Temp.
The error "File does not begin with '%PDF-'" appear because there are no access rights to create and then delete temporary files for your final PDF file. So you have an option to assign "Modify" access right to your root folder or transfer temporary files for PDF in folder Temp and assign "Modify" only to folder Temp (this is more secure).
try with <%#LANGUAGE="javascript" %>
insted of <%#LANGUAGE="javascript" CODEPAGE="65001"%>
Just need to remove CODEPAGE="65001"

Resources