Showing posts with label Environment. Show all posts
Showing posts with label Environment. Show all posts

December 07, 2020

C# get windows user app data folder path

 Hi folks,

Today I will explain to get the folder path of the windows user specific app data for storing any program (app) based information in C# (.NET Framework, .NET CORE, .NET 5)


Source

using System;

using System.IO;

namespace NETFrameworkConsoleApp1

{

    class Program

    {

        static void Main(string[] args)

        {

            string dir = Path.Combine(

                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),

                "FolderName"

            );

            Console.WriteLine("User Appdata Path: \n " + dir);

            Console.ReadLine();

        }

    }

}


Hope this helps you to customize your requirement.

References

https://docs.microsoft.com/en-us/dotnet/api/system.environment?view=net-5.0

Please share your comments and feedback to psrdotcom@gmail.com


November 21, 2018

Connect to remote Oracle database server from RedHat Linux 7 using Oracle InstaClient

Hi friends,

I have come across a situation, where I need to connect to remote Oracle database server from RedHat Enterprise Linux (RHEL) 7. I found a way of using the Oracle InstaClient instead of installing the full Oracle DB which internally consists of Client.

Pre-requesites


  1. Linux mahcine (I tried with RHEL 7) with following softwares
    • Java (JAVA_HOME should be available)
    • Development Tools (RHEL 7 tools like gcc etc.)
  2. Another machine where Oracle server is installed with the following config
    • Database schema should be available
    • Users should be available instead of system/sysdba users
  3. Both machines shall be reachable to each other via ping.

Note: You should know the database server SID/service name.

Procedure

Download


  1. Download the insta client from Oracle Official Page
  2. In my case, I have downloaded the "Instant Client for Linux x86-64"
  3. Accept the license agreement
  4. Click "oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm" to download
  5. Optionally, you can download the "oracle-instantclient18.3-sqlplus-18.3.0.0.0-1.x86_64.rpm" to have sqlplus command line utility for testing
  6. Alternatively, you can download the zip files and download the same to install.
  7. In my case, I am going with RPMs.

Install


  • Install the downloaded RPMs
    • #> yum install oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm
    • #> yum install oracle-instantclient18.3-sqlplus-18.3.0.0.0-1.x86_64.rpm
  • While installing, it asks for locations, accept the defaults by pressing the "Enter" button

Note: If any dependencies are there, please install those.

Environment Variables


  • Create a oracle_env.sh file and setup your variables
    • #> gedit /etc/profile.d/oracle_env.sh
    export ORACLE_HOME=/usr/lib/oracle//client/
    export TNS_ADMIN=/usr/lib/oracle//client/
    export PATH=$ORACLE_HOME/bin:$PATH
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH



    • Save your file
    • Source your file with following command
      • #> source /etc/profile.d/oracle_env.sh

    tnsnames.ora


    • Create tnsnames.ora file in your $ORACLE_HOME with following syntax

    localsid = (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = ))
        (CONNECT_DATA =
          (SID = )
        )
      )

    • Instead of SID, you can use SERVICE_NAME also.

    Connect


    • You can test the connection
      • #> sqlplus @


    You should be able to connect to your remote database.

    Hope, it is useful for you.

    Please send your comments and feedback to psrdotcom@gmail.com

    December 12, 2013

    PhoneGap Installation and running Sample Application on iOS



    Pre-requisites


    Softwares

    •     iOS SDK
    •     Xcode command line tools
    •     Node.js
    •     Cordova (Zip)

    Setup Environment Variables


    •     NODEJS_HOME
    •     CORDOVA_IOS

    PATH Environment Variable Update

    1) Open a terminal prompt

    2) Type sudo vi /etc/launchd.conf (note: this file might not yet exist)

    3) Put contents like the following into the file

    # Set environment variables here so they are available globally to all apps
    # (and Terminal), including those launched via Spotlight.
    #
    # After editing this file run the following command from the terminal to update
    # environment variables globally without needing to reboot.
    # NOTE: You will still need to restart the relevant application (including
    # Terminal) to pick up the changes!
    # grep -E "^setenv" /etc/launchd.conf | xargs -t -L 1 launchctl
    #
    # See http://www.digitaledgesw.com/node/31
    # and http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x/
    #
    # Note that you must hardcode the paths below, don't use enviroment variables.
    # You also need to surround multiple values in quotes, see MAVEN_OPTS example below.
    #

    # Nodejs Installed path. By default the path is your home directory->.npm directory path
    setenv NODEJS_HOME $HOME/.npm

    # Choose the location where you have unzipped the cordova iOS folder
    setenv CORDOVA_IOS /cordova-ios


    PATH Environment Variable Update

    create .bash_profile file in your home folder
    Enter the following content

    #!/bin/bash
    export PATH=$PATH:$NODEJS_HOME:$CORDOVA_IOS/bin

    Install phonegap

    If you are behind a proxy please set the proxy to npm (Node.js) command
    Syntax:-
    (For HTTP) $ npm config set proxy http://proxy.company.com:port
    (For HTTPS) $ npm config set https-proxy http://proxy.company.com:port

    Run the install command

    $ sudo npm install -g phonegap
    $ sudo npm install -g cordova

    Note: If you face any errors
    • Remove the .npm directory from the home folder
    • Upgrade npm (sudo npm install -g npm)
    • Clear the global npm cache (sudo npm cache clear)
    • Clear the user npm cache (npm cache clear)

    Create Project

    Syntax: phonegap create
    $ phonegap create hello com.example.hello "HelloWorld"

    By default the skeleton folder structure will be created.
    Note: if you didn’t get the default skeleton (www, js, css folders and other files), please copy from the sample-hello-world project of phonegap to your www project folder

    $ cd hello
    $ cordova platform add ios
    $ phonegap build ios



    Adding Plugins to your project

    Pre-requisites

                •           Install Git
    Tip: If you are behind a proxy then please add it your configuration
    Syntax: git config —global http.proxy http://proxyusername:proxypassword@server.company:port
    Ex: git config —global http.proxy http://abc:123@xyz.com:8081

                •           Add git\bin to your PATH environment variable
                •           You need to download the git files from https://git-wip-us.apache.org. So make sure that the above specified URL is not blocked by your firewall
                •           Navigate to your project directory in command prompt by changing the directory
    cd

    Note:
    If you have some issues download cordova zip (unzip cordova-ios zip) and copy it to your home directory-> ~/.cordova/lib/ios/cordova/3.2.0/

    Install Plugin

    Syntax: phonegap local plugin add
    Ex:- phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git

    Tip: If this doesn’t run then try with cordova
    Syntax: cordova plugin add
    Ex:- cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git

    Add the Feature to config.xml (Ex: Accelerometer)

        name="Accelerometer">
            name="ios-package" value="CDVAccelerometer" />
       


    Remove Plugin

    Syntax: phonegap local plugin remove
    Ex:- phonegap local plugin remove https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git

    Tip: If this doesn’t run then try with cordova
    Syntax: cordova plugin remove
    Ex:- cordova plugin remove https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git

    Alternative
    You can install “plugman” to plug and play with plugins by following this link
    Using Plugman to Manage Plugins
    Note: plugman doesn’t take proxy

    References

    PhoneGap Installation and running Sample Application on Windows


    Pre-requisites


    Softwares

    1.       Node.js
    2.       Ant (Zip)
    3.       Java SDK 1.7
    4.       Android SDK
    5.       Eclipse (Zip)
    6.       Cordova (Zip)

    Setup Environment Variables

    1.       NODEJS_HOME
    2.       ANT_HOME
    3.       JAVA_HOME
    4.       ANDROID_SDK
    5.       CORDOVA_ANDROID

    PATH Environment Variable Update

    Add NODEJS\bin;ANT_HOME\bin;JAVA_HOME\bin;ANDROID_SDK\tools;ANDROID_SDK\platform-tools

    Install phonegap

    If you are behind a proxy please set the proxy to npm (Node.js) command
    Syntax:-
    (HTTP) C:\> npm config set proxy http://proxy.company.com:port
    (HTTPS) C:\> npm config set https-proxy http://proxy.company.com:port

    Run the install command

    C:\> npm install –g phonegap
    C:\> npm install –g cordova
    Note: If you get any ”shasum (Checksum)” error, then please
    i)                    clear the npm and npm-cache directories from %User%/AppData/Roaming folder
    ii)                  Install the latest npm version
    Currently it is 1.3.21
    npm install https://registry.npmjs.org/npm/-/npm-1.3.21.tgz
    npm install -g phonegap


    Create Project

    Syntax: phonegap create
    Ex: phonegap create FirstPhnGpPrj com.pg.firstphngpprj PhoneGapPrj1

    ·         Now it will create some folders and corresponding files (HTML, CSS, JS)
    ·         Change the directory to your project directory
    o   Ex:- C:\> cd FirstPhnGpPrj

    Add Platform

    Syntax: cordova platform add
    Ex:- C:\FirstPhnGpPrj> cordova platform add android

    Tip:
    If it’s not working then you need to install the cordova (npm install –g cordova)
    Copy the cordova-android\bin from your downloaded&extracted zip file to %User%\.cordova\bin

    Run Phonegap for Individual Platform

    Syntax: phonegap run
    Ex:- C:\FirstPhnGpPrj> phonegap run android

    1.       By now, you will be getting your Android project hierarchy in your project_folder\platforms\android\
    2.       Import the existing android code from your Eclipse
    3.       Create\manage AVD
    4.       Run the project

    Adding Plugins to your project

    Pre-requisites

    ·         Install Git
    Tip: If you are behind a proxy then please add it your configuration
    Syntax: git config –global http.proxy http://proxyusername:proxypassword@server.company:port
    Ex: git config –global http.proxy http://abc:123@xyz.com:8081

    ·         Add git\bin to your PATH environment variable
    ·         You need to download the git files from https://git-wip-us.apache.org. So make sure that the above specified URL is not blocked by your firewall
    ·         Navigate to your project directory in command prompt by changing the directory
    cd

    Install Plugin

    Syntax: phonegap local plugin add
    Ex:- phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
    Tip: If this doesn’t run then try with cordova
    Syntax: cordova plugin add

    Remove Plugin

    Syntax: phonegap local plugin remove
    Ex:- phonegap local plugin remove https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
    Tip: If this doesn’t run then try with cordova
    Syntax: cordova plugin remove

    Alternative

    You can install “plugman” to plug and play with plugins by following this link

    References


    Featured Post

    Java Introdcution

    Please send your review and feedback to psrdotcom@gmail.com