Conflict between relative and absolute path while using two exe file in delphi - delphi

I have one exe say myApp.exe in C:\MyProject folder. It writes logs in logfile say tracefile.log which is also there in C:\MyProject.
Now I have to make a schedule task say Schedule1.exe which will also write in logfile tracefile.log located in C:\MyProject.
Ok, I created Schedule1.exe and kept it in same folder C:\MyProject folder and made schedule taks using this exe.
Problem: Schedule1.exe cannot pick the path of logfile when I give relative path of logfile as ".\tracefile.log". But when I give full path like "C:\MyProject", it picks the logfile path and writes on it.
Please suggest what could be the problem?

Relative paths are relative to the working directory of the process. The working directory of the process is determined at process startup, and may not be the directory that contains the executable. What's more, the working directory can change during the processes life.
It seems to me that you should be giving a full path to these files. You need to get hold of the directory in which the executable lives. That is
ExtractFilePath(ParamStr(0));
So you should be using this code to name your file:
ExtractFilePath(ParamStr(0)) + 'tracefile.log'

Related

How to prevent local msmpi installation from loading system wide msmpi.dll

I'm writing a console app for windows that sets up an environment and launches (popen) various hpc-apps using msmpi mpiexec.exe.
I have an msmpi installation installed locally to the application I'm writing. All works fine and parallel processing is OK.
However, as soon as I happen to have a system installation of msmpi as well (as installed by e.g. msmpisetup.exe), my applications stubbornly loads the Windows/system32/msmpi.dll instead of the msmpi.dll that I point at using PATH. Since the system msmpi.dll is of a different version, my apps does not run.
The PATH env.var. is set within my app, and it is apparently inherited correctly by the child processes, including mpiexec.
The only remedy I've found is to either (1) Rename system32/msmpi.dll or (2) place a copy of "my" msmpi.dll into every folder in which I have a parallel executable. Both remedies are... not nice.
How can I prevent my apps from selecting the system32/msmpi.dll and use the instance that's in the PATH instead??
Thank you for any advice.
N
The standard DLL search order in Windows is documented to be
The directory from which the application loaded.
The system directory. Use the GetSystemDirectory function to get the path of this directory.
The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
The current directory.
The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.
If you want your application to check a specific location first before using the system locations, you can call SetDllDirectory in the parent application before letting it execute other binaries that require a particular DLL.

Is '/' necessary in the starting of a pathname?

What is the difference between these two pathnames? Is / necessary to put in start for going in a folder?
assets/myImg.png
/assets/myImg.png
/assets/myImg.png is an absolute path. It means no matter where do you call the path from it's always the same. assets/myImg.png is relative path to your current directory
You haven't mentioned an OS, so given the leading / I'll assume we're on a Unix-like system.
/assets/myImg.png
This is an absolute path. It's going to look in the root directory of your file system for a folder called assets and go from there.
assets/myImg.png
This is a relative path. It's going to look in the current working directory, which is likely the directory where you started your current program. If you're using this from the command line, it's going to look starting from the current directory of the shell (i.e. the thing you change with cd).

Changing output directory in MVC Application

I am having a problem with my MVC application after I set a different output folder instead of the default Bin folder . I also deleted the bin folder .
This resulted in Global.asax file exception "Cannot load the type Global.Mvc application" during application runtime.
I am trying to get rid of all the bin folders to have just one output folder for my application . I would like to know if it is possible at all to get rid of the bin folder completely . Am I missing some setting here or is it a must to have bin folder ?
I find a way to change bin folder.
Just like you say, When we change the default output folder:"bin\", then it will display some exception, Maybe that's a bug from visual studio.
Actually a lot people want to change the default bin folder to some RAM disk position, then it will save HDD life(don't let the HDD always write again and again), also very fast for read and write.
We can't change the default address, but we can change it use this way(delete bin folder before):
Open CMD.exe(administrator mode), put this code and execute:
mklink /d "Your project folder\bin" "new address(like RAM disk address)\bin"
mlink can redirect the original folder position to new position. Then, all fine such like you need.

File Exist condition issue in Jenkins

I am working on product testing automation. I am using Jenkins to create a job that will first browse some file in a directory. But I got a problem with Conditional Step in File Exist condition. It is not working when I search *.job file, it only works with specific file name I put. Sorry I don't have enough reputation to post picture :)
Anyone can help me solve this issue. Thank so much for reading
I don't think File Exists supports more than one file, you could try the "File match condition". Definitions below:
File exists Run if the file exists.
The file is expanded using the Token Macro Plugin. If the file is
relative, then it is relative to the Base directory. If the file is
absolute, then it will be tested on the Node that contains the Base
directory (the master for $JENKINS_HOME and Artifacts dir).
Files match Run if one or more files match the selectors.
Separate multiple includes or excludes patterns with a comma. e.g.
Includes "target/site/**/*.html,target/site/images/" Excludes
"**/*.gif" If no includes pattern is configured, then the pattern
"**" will be used, which matches all files in the directory and all
sub directories. The includes and excludes are Ant Patterns.

Rikulo stream base folder

Is it possible to choose to serve files only from a specific folder using Rikulo stream? I've tried
new StreamServer(uriMapping: _mapping, homeDir: 'my/web/webapp/app')
but I'm not getting the desired results as it's still serving files under the 'web' directory.
When homeDir is specified with a relative path, it is assumed to be relative to the current directory (Directory.current.path). I think it is not what you expect. You can use an absolute path for better control.
After examining the code, I think the relative path is better to base on the root directory rather than the current directory. Please follow Issue 29 for details. Also refer to the sample app here.

Resources