So i'm trying to make a configuration for my app, although it doesn't seem to load or save anything from/in it.
Here's the code upon creation:
ini_open(working_directory + "\properties.ini");
global.width = ini_read_real('screen','width',640);
global.height = ini_read_real('screen','height',480);
ini_close();
Here's the ini file:
[screen]
width = 1280
height = 1024
when i return global.width and global.height values they're still 640;480 but not as stated in the ini file, which means it doesn't even load values from the file. I was wondering, maybe I need to compile the executable and then run it as administrator, but I doubt that there could be a problem with permissions. I also added properties.ini file to "Included Files" folder so it would come with compiled exe.
This seems weird, but now it works. Actually the *.ini file isn't saved the same place where exe is. I just found out that it saves everything in %localappdata%// . Also it looks to be working better without dir shortcut "working_directory". So thanks, anyway
Related
I need something that can copy a specified file any and everywhere on my drive (or computer) where that file already exists; i.e. update a file. I tried to search this site, in case I'm not the first, and found this:
CMD command line: copy file to multiple locations at the same time
But not quite the same.
Example:
Say I have a file called CurrentList.txt, and I have copies of it all over my hard drive. But then I change it and I want all the copies to update. So I want to copy the newer one over all the others. It could 'copy if newer', but generally I know it's newer, so it could also just find every instance and copy over it.
I was originally going to use some kind of .bat file that would have to iterate over every folder seeking the file in question, but my batch file programming is limited/rusty. Then I looked to see if xcopy could do it, but I don't think so...
For how I will use it most, I generally know where those files are going to be, so it actually might be as good or better if I could specify it to (using example), "copy CurrentList.txt, overwriting all other copies wherever found in the C:\Lists folder and all subfolders".
I would really like to be able to have it in a context menu, so I could (from a file explorer) right click on a file or selected files and choose the option to distribute it.
Thanks in advance for any ideas.
Use the "replace" command...
replace CurrentList.txt C:\Lists /s
I am currently facing an issue which I don't know how to fix. I got the following Julia code:
while true
print(watch_file("test"))
end
So this should get me all the file changes in the directory named "test". At least on windows.
Now thats all well and good, and it kinda works, at least for creating a file or moving a file to that directory. This is an example of what I get:
("New Textfile.txt",Base.FileEvent(true,false,false))
But when I delete or rename that file, I don't get the filename of the file deleted or renamed.
("",Base.FileEvent(true,false,false))
Is there a different method/function I can get the filename with, even when the file is deleted or renamed? Or even better, a way that archives this and is cross-platform-compatible? Any help appreciated.
EDIT: If you could give me an alternative that supports recursive monitoring, that would be even better.
In Linux, Julia 0.4.5 and 0.4.3 watch_file returns file name always. It is a very platform-dependent feature (like in Node.js https://nodejs.org/api/fs.html#fs_caveats) and only manual polling can be truly platform-independent solution.
The file is inside the directory where the software is. I am trying to add the text file to the memo box.
procedure TForm4.FormCreate(Sender: TObject);
var
dir : string;
begin
Form4.Caption:='Abateri instrumente';
dir := GetCurrentDir;
Memo1.Lines.LoadFromFile(dir+'\abateri.txt');
end;
In your specific situation, you should load the file with the code
Memo1.Lines.LoadFromFile(dir+'\abateri.txt.txt');
This is because in the below screenshot that you provided, the extension of the Project3 file is hidden, which loads to the conclusion that the option to hide known file extensions is enabled. Yet the one for the abateri.txt file is shown, which can only lead to the often seen double extension mistake.
Either rename your file and remove the redundant part (the first .txt, which is preferred) or use the double extension in your code.
I would also suggest disabling that option in Windows Explorer:
Tools > Folder Options > View > Uncheck the "Hide extensions of known file types"
In addition to the above, you should always build up paths with the TPath.Combine function call to ensure that they are correct.
You can see the documentation of it here
The file is inside the directory where the software is.
In that case, looking in the working directory is the wrong approach. There's no reason why the working directory should be directory where your executable resides. You need to use:
Dir := ExtractFilePath(ParamStr(0)); // the directory where the executable resides
TPath.Combine(Dir, FileName); // TPath is from the System.IOUtils unit
Of course, your other problem is that you got your file name wrong. The file is actually named abateri.txt.txt.
It is exactly wnat the title says I have beenlooking for quite sometime and haven't found anything the main use would be as a auto run file to collect error reports from our offic computers
You could do this if you run the program from the USB drive itself, and declare wherever the file is stored as the "working directory" as the USB may have different IDs for different computers...things get messy.
My recommendation is to use File in Java, and Path (http://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html)
A warning though is that if you copy a directory (folder), the files within that folder are actually not automatically copied...its just the way it works. (more here: http://docs.oracle.com/javase/tutorial/essential/io/copy.html)
Assuming the file is always in the same place going to the same place. For example:
Files.copy(source, destination, options);
or you can open text file and read from it for a more advanced method:
Files.copy(InputStream, path, options);
etc.
I have a problem when trying to upload multiple files to one WinSCP directory, i can manage to copy just one single file, but the problem is that i need to upload many files that are generated by a software, the names are not fixed ones, so i need to make use of wildcards in roder to copy all of them, i have tried many variants on the code, but it all was unsuccessful, the code i am using is:
open "sftp://myserver:MyPass#sfts.us.myserver.com" -hostkey="hostkey"
put "C:\from*.*" "/Myserverfolder/Subfolder/"
exit
This code does actually copy the first alphabetically named file, but it ignores the rest of the files.
Any help with it would be much appreciated
Try this in script
Lcd C:\from
Cd Myserverfolder/Subfolder
Put *
Try and do all manually first so you can see what's going on.