-1

I am trying to access a text file(license key file) in my angular 8 application which is located under wwwroot folder but it should not be in js folder. if anybody has idea how to configure this through web.config.js/tsconfig.js or any other file change. (note: my application is using webpack.config.js file not the angular.json file)

Your help will be a great appreciation for me.

thanks

2 Answers2

0

You can just import it

import { license } from './license';

consider putting your data to environment folder. Otherwise you can use http call.

See this for more info.

playerone
  • 987
  • 3
  • 22
  • 44
  • thanks for reply . one thing is here i have to use this license file inside a component folder like this "UI/Origin/shared/a.componet.ts" here is my code lt.RasterSupport.setLicenseUri("/license/Leadtools.lic.txt", null, null); so how i can use this in my scenerio and i have no environment folder. – Anver Sadat Feb 02 '21 at 09:10
  • Then use HttpClient to read txt file. this.http.get('./Leadtools.lic.txt').subscribe(data => { console.log('data', data); }) – playerone Feb 02 '21 at 09:38
  • By using the " this.http.get('/leadview/Leadtools.lic.txt', { responseType: 'text' }) it desnt wrk but not when we use this.http.get('/js/leadview/Leadtools.lic.txt', { responseType: 'text' }). it never works actually when we try to access the file in js folder but no the other folder in wwwroot so any seeting we need in webpack.config for this? – Anver Sadat Feb 02 '21 at 10:41
  • that's because there is a option to copy that file in root folder with angular.json. there is a field assets. – playerone Feb 02 '21 at 11:01
  • for me in angular projects there is no need to configure webpack at all... can you check this one: https://stackoverflow.com/questions/45578665/push-assets-folder-to-public-directory-with-webpack – playerone Feb 02 '21 at 11:02
  • 1
    I have done it by change in configure method in startup.cs file and adding my folder. It worked like a charm. Thanks for your great help bro.. – Anver Sadat Feb 03 '21 at 09:06
0

I have done it by change in configure method in startup.cs file and adding my folder. It worked like a charm. Thanks guys for your great help