How i can deploy a genexus c# in a shared hosting? - c#

I need to deploy a genexus C# in a shared hosting.
I only have access to the ftp, so my idea is put in public_html the files that i have in C:/Models/Project/CSharpModel/web but i don't know if this will work because i never put this archives in a shared hosting, only in a IIS.
Someone can explain me how the genexus will create the database/tables of my application?
There's some else that i have to do?

You need to take of the database reorganization yourself. Keep in mind thou, that GeneXus has a feature called Export Reorganization that will allow you to export a reorganization program, and the doc tells you how to execute that reorg program.
Also, I wouldn't copy the entire web directory in your shared folder. You should use the Deploy Engine in order to get the only minimum required file for your app.
Edit: You need to copy the folder where all the files are placed... commonly there's a folder named after the Deployment Unit's name, and inside that folder, on folder for every deploy you've made. Those folder are named after a timestamp, so you'll easily find the latest deploy.

Related

How to include externel user files into UWP side-loading package?

Say I use some .json files to descript some object data which effect to the program's behavior, I hope to use these files in the following scenarios
The default values, for this purpose, I need a set of files follows with the application to be packed and installed.
I wish it could be edited by human manually. (Because something have no interface to be modify on UI)
Both user and the program need to kwnow the location the files will be placed after installation.
In debugging stage, I could put these files in the user\AppData\Local.. folder and I know how to access them, but I don't know how to put files into the package and will them generated to anywhere after install?
Thank you for any suggestion.
ps.
I use the "Blank App (WinUI 3 in UWP)" template to create my
application.
I'm new in UWP and WinUI, I used to write traditional Windows Form programs.
How to include externel user files into UWP side-loading package?
You could place the json file into app's project and set the file property as Content, then it will deploy into installtion folder after package install. and please note the json file is readonly in the installtion folder.
so you could call CopyAsync method copy the file to the destination folder that app's local folder with full permission.
For more details about file access permissions please refer this document.

Create app with data already present on install

I'm currently programming an app that need to access to some Excel files.
So what I need is to create a folder in the app files with these Excel files in it but I want that folder to be created at the app install, so they would be accessible for every device that install the app.
The files also need to be modifiable in the future by the user.
The problem is that I don't know how to do it right. Should I just create a new folder in the Solution Explorer and put the Excel files in it ? Should I create the folder programmatically and force the user to put them manually in that folder ?
I don't really know how to do it so that the application will not be too complicated to be modified by the user.
EDIT : Also, if I put the files in the Assets, will the user be able to change them later ?
So what I need is to create a folder in the app files with these Excel files in it but I want that folder to be created at the app install, so they would be accessible for every device that install the app. The files also need to be modifiable in the future by the user.
For your requirement, you could use ApplicationData.LocalFolder to store Excel files, LocalFolder has full access permission. LocalFolder exists in the app's sandbox path and will be created after the app is installed.
Also, if I put the files in the Assets, will the user be able to change them later ?
Assets folder exists in Windows.ApplicationModel.Package.Current.InstalledLocation and it is read only that often use to store some static resource. You can't modify the file at run time.
For more details about file access permissions please refer this document.
Forget the installer. It is deprecated and the new apps on Windows are installed over the store.
If you want to copy some files (Excel templates), you have to put them in your resources. At startup you can check if there is a folder in your App-Data folder with your files, if you don't find them, you can copy it from your resources. So even if the file is deleted, your app can copy them in the next start.
If you use Windows Forms with .NET, you can check this page:
https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.application.localuserappdatapath?view=netframework-4.8
If you are writing an UWP-app, check this page:
https://learn.microsoft.com/en-us/windows/uwp/design/app-settings/store-and-retrieve-app-data

How to attach file to windows service?

Is it possible to attach a flat file to windows-service?
My windows-service uses few flat file (for data purposes). Usually, if it's a normal executable I would place those files in the same directory as exe. How can I achieve that with windows-service?
I've done some research on this, but all I found was:
1. Pass a path to those files as a parameter to windows-service.
2. Make a fixed path and just require those files there
But I don't like those solutions. I was wondering if it's possible to attach those files to the windows service while installing it?
How about adding these files inside the project as Embedded Resources? They won't show up on the disk, but you could still properly read them from inside the assembly itself.
Here's some reference: https://support.microsoft.com/en-ie/kb/319292
You can look up the directory that your application is installed in at runtime, using the Application.StartupPath property from System.Windows.Forms. This works for both applications and services. You should avoid hard-coding the path that you think your application is installed in, because the end user may have installed it somewhere else. You should also avoid using the current directory (i.e., opening the file by name only, without a specific path) because the user may be running your application with a different current directory.
Note that installutil does not make a copy of your service executable. So the service runs from the same directory that it was in when you installed it, and any files you place in that directory should still be there when the service is running.

How to create folder in mvc solution directory so that it is included in project?

I am new in mvc and c# and I can't solve following problem:
I am trying to create a folder named "Items" in solution folder.
I have tryed to use CreateDirectory method:
Directory.CreateDirectory("~/Images");
But it didn't work for me - folder wasn't created ..
Partly working solution was to create a folder by :
Directory.CreateDirectory(Server.MapPath("~/Images"));
"Items" folder was created, but it is not included in the solution:
How to create folder in solution directory so that it is included in project ?
(I needs to by done by code not by hand)
You need to understand what solution and csproj file is used for
In general, they're being designed and used for development with Visual Studio, and once the project is compiled, all these files will be ignored and excluded from the deployment package
Directory.CreateDirectory(Server.MapPath("~/Images"));
The code above simply create the directory if not existed yet in the deployment package at run-time, so you won't see it in your solution unless you run the project locally (either debug/release mode, it does not matter here). However, everything will run normally in hosted environment (ex: IIS).
For your information, here's the brief of what solution and csproj is
solution (.sln) file: contains information to manage one or many individual projects, contains build environments (for each project), start up mode (useful when you want to start multiple projects in one run), project dependencies and so on. Take a note that VS also read from suo file (solution user options) which is used to defined user-custom preferences (you should not include the .suo file in the version control, because it's custom settings)
csproj file: define the structures of project, what the namespace is, what is static folders, embedded resources, references, packages, etc.
Lastly, if you create the folder manually, VS will auto include that folder into deployment package AND csproj, but depends on the file type, you might need to change the Build Action and Copy To Output Directory in file properties.
Hope it helps.
A deployed web application on a web server doesn't have any notion of Visual Studio solution or projects. So the Directory.CreateDirectory(Server.MapPath("~/Images")) is the correct way to create a folder inside your web application at runtime but we cannot be talking about including it into a solution because this hardly makes sense in a pre-compiled web application. If you create the directory on your local development machine, you could always manually include the folder to the corresponding .csproj file, but at runtime this will not make any difference whatsoever.
The reason I wanted to create a folder (if didn't exist) was to make sure it exits before I try to store image in it.
After reading posts here and a few google searches I have concluded that the proper way to handle image upload would be
To create (In my case) folder "Images" by hand to be sure it exists
Then storing uploaded img in existing folder:
string path =Server.MapPath("~/Images/"+ UploadedImageName);
file.SaveAs(path);

C# vista does not giving access to create folder

In my project I have to create some files and directories into my app folder which is into program files. But in vista it is giving me error that I dont have access to create file.
What should I do now for giving access ? Also it not let me access the registry !!
The program folder is not the place to store application data. There is an %APPDATA% folder for that - you are supposed to store your data there.
Use System.Environment.SpecialFolder and System.Environment.GetFolderPath to obtain the path leading to the correct directory.
Also, you need to differentiate between just creating a folder and putting some files in there (for example during installation) or writing to the program folder at runtime, while typically running under a limited account.
The reason for this difference is simply that installation routines and setups run with elevated privileges under Vista / Windows 7, thus those are allowed to create folders and files there. Still, those files are not supposed to be written to at runtime of your application.
So, what is it you want to do? Write data at runtime, or put some files (i.e. dependencies) in your application folder at a single time? If it's the first, comply with the rules and use the %APPDATA% folder. If it's the second, create an installer / setup routine.
Vista and Win 7 have the Program Files folder locked down so you can't write to it with a basic user account. If you need to create folders there, then you should do it in the installer. Otherwise you can use the user's Application Data folder in their profile.
The only other way is to modify the permissions on the installation folder at install time.
Can you turn the UAC off? Or Login as administrator? The chances are that you are creating the folder in the wrong place.

Categories

Resources