C# - Recommendations for extracting files from .tgz file - c#

I've got a Windows C# program that I want to extract a file (or directory) from a .tgz file without compromising the integrity of the .tgz file. This file comes from a linux system and has permissions set on it and what I need to do is remove a directory from it, and then send it to another linux machine to run. I tried using the Chilkat component but it removed all the permissions and casing on the sub folders so it wouldn't run on the other linux box.
Any suggestions as to how I can do this (if it can be done on a Windows machine using C#) would be greatly appreciated.

Have you tried to use sharpziplib, I have used it in the passed with success

Related

Access to path denied while reading a dll from Program Files which is actually got from a nuget package

Access to path denied error is encountered in Program files (x86),
while working with a DLL that is got from nuget package: AODL for reading ODF files - https://www.nuget.org/packages/AODL/ after I created a MSI file using SETUP Project
In the code, I don't suspect the file creation part for I create this file in the user chosen file conversion path but NOT IN PROGRAM FILES folder path:
File.WriteAllText(targetFileName, sb.ToString(), Encoding.UTF8);
That's why I simply suspect the DLL, please let me know how I could find the error and fix this.
A bunch of directories - both Programm Files, the root directory of the System Drive, Windows - are heavily protected by NTFS rights. Writing them is usually a plain "no-go". Unless you run around with full administrative rights - wich only Instalers and very rare Adminsitrative tools should even consider - you will not be able to write there.
However you indicated this happens on a read. Reads being blocked like that is very unusual. You need to check what rights are set on those folders and why. Maybe the installer accidentally copied the rights from your computer, wich only makes sense with your users and groups? Maybe Windows or a third party broke those rights? Not a lot of options I can think of that could apply here.
For this application, even for reading the DLLs from the Program Files folder I needed Admin rights so I forced the application to have such rights for execution.
The below line for the newly created application manifest file is changed and that solved the issue.
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
The fix is explained well in How do I force my .NET application to run as administrator?
The reasons are stated well in https://stackoverflow.com/a/50588465/129130

IronOcr reads text locally, but blank text in remote server

Whenever I attempt to read a PDF via OCR, it works correctly when running locally on my development machine, and all text parses correctly. However, the same code (and same license) in our remote server is reading blank text.
In the screenshot below, this is a remote debugger attached to the server and while I've confirmed it does read the file correctly (into fileBytes), invoking ReadPdf reads an empty string for text and finds no pages.
I'm not sure what can cause. I have checked folder permissions in Temp, set a custom temp directory, and still it reads blank. It also shows the same behavior when reading TIFF files (ReadMultiFrameTiff(...)) even when a file path is used in the parameter.
Note: PdfReader is another library that is only used to get the page numbers.
Thanks!
In this case, the solution was updating the Visual C++ runtimes (both x86 and x64) on the remote server. Apparently the remote server did not have the latest version installed.
These other suggestions were from their support ticket that I had tried prior to updating the runtimes:
Please also set an installation path that has full permissions to the IIS user: https://ironsoftware.com/csharp/ocr/object-reference/html/T_IronOcr_IronOcrInstallation.htm
It could also be that something could be missing in the DLL assemblies. Please try to clear all cache and temp folders, then download the package again into a CLEAN app.

C# - Download .exe that launches with parameters

I was wondering if it was possible to host a .exe file, that when downloaded has parameters associated with it, so once run can read them on the host computer.
I have looked into 'ClickOnce' with the xml manifest (similar to Java WebStart) but I am concerned about lack of native functionality in Chrome and Firefox (this is a must). I have also looked into storing it in the executable filename, but the 255 character limit concerns me.
I was wondering if there was any way to pass parameters to an executable that is downloaded from a website, where I am hosting the website?
Well, sort of.
Most executables that does something like this, tucks on some data at the end of the executable before it is downloaded. As such the executable reads its own file and finds the data at the end.
Adobe Creative Cloud uses this for instance. If you pick an application to install on the website, a small stub executable is downloaded, figures out if it has to install Creative Cloud shell application, and then launches it with information about which program to install.

Updater.exe built into app.exe

Currently I have 2 exe files. app.exe and updater.exe. When app.exe finds out that there is new version available it runs updater.exe, which downloads and replaces it.
I'm wondering if it's possible to build updater.exe into app.exe. On app start it should check if there is updater.exe in the directory and if it's not than extract it. Any help appreciated.
You can integrate updater.exe as a resource into app.exe. The following SO post shows how to extract it at run-time:
Embedding an external executable inside a C# program
Note that, if your application is located in the default application directory (C:\Program Files, or, more generally, %ProgramFiles%), you will not have permissions to create a file in the same directory (which is a good thing). Thus, you might need to extract updater.exe into a temporary directory that the current user has write permissions to (such as Path.GetTempPath).
When I'm understanding you correctly you need to pack you updater.exe into you app.exe as ressource. Extract it, when App.exe starts.
But I can tell you, this idea with replace is bad. You should choose a MSI package to deploy your application.
For traversing and listing directory contents, see http://msdn.microsoft.com/en-us/library/system.io.directory.aspx
For accessing your embedded resources, see http://msdn.microsoft.com/en-us/library/xc4235zt.aspx
For writing binary data to disk, see http://msdn.microsoft.com/en-us/library/system.io.binarywriter.aspx
For running an exe from disk, see http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx

Access to SQL CE database in Program Files directory

I've read a bit that putting a.NET 2.0 SQL CE database in the program files directory where the application is installed is a bad idea. I'm running into the following error:
Access to the database file is not allowed. [ File name = C:\Program Files (x86)\MyCompanyName\MyApplicationName\MyCEDatabaseName.sdf ]
So I've heard, put it in Common Application files.... I'm not sure where that is, and I've read that the installer may drop the file there with the same permissions. I've also read that people have moved their file there and had issues.
Is it possible to change the ACLs of the file in the program files directory when the installer drops it there? I already have hooks into the application from the MSI to collect and set configuration options. I haven't found a good example of how to change the permissions on ONE file.
Then I've read to store it in the user's application data, but if you're installing the application 'for everyone' where will the file go?
Thanks for your time.... confused.
I assume you are using a MSI package. In this case you can use CommonAppDataFolder which is resolved to "C:\ProgramData".
However, this is also a per-machine location, so it requires the same privileges as Program Files. I think you heard about Application Data folder (AppDataFolder) which is a per-user location (something like "C:\Users\\AppData\Roaming"). It doesn't have permission problems.
If you want to use a per-machine location a solution is to use the LockPermissions table:
http://msdn.microsoft.com/en-us/library/aa369774(VS.85).aspx
This is a bit complicated because of all the permission flags. So if your setup authoring tool doesn't offer support for setting permissions, I suggest a simpler approach: use xcacls.exe as a custom action:
http://support.microsoft.com/kb/318754
This way all users can gain access to your database file.

Categories