Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 751353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:39:26+00:00 2026-05-14T14:39:26+00:00

I have a license file that I need to access at runtime in order

  • 0

I have a license file that I need to access at runtime in order to create pdf-files. After I have created the in memory pdf, I need to call a method on that pdf to set the license, like this:

pdf.SetLicense("pathToLicenseFileHere");

The license file is located in the same project as the.cs-file that creates the pdf, but is in a separate folder. I cannot get this simple thing to behave correctly, which makes me a bit sad, since it really shouldn’t be that hard. 🙁

I try to set the path like this:

string path = @"\Resources\File.lic";

But it just isn’t working out for me.

Edit:

A bit more info. I should mention that this is a web service which returns pdf:s as byte[]. The web service creates the pdf:s, and during this creation process I need to set the license file so as to remove any watermarks from the pdf document. The pdf itself is not saved to disc, and only needs to access the license file once when it is created.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:39:27+00:00Added an answer on May 14, 2026 at 2:39 pm

    So the file is in your project and you need it in the same folder(structure) within your folder where your application is.

    If i’m correct there are two approaches to get this to work:

    1. Mark the file as Content, so that VS will copy it into the folder of your .exe file
    2. Add it as resource to your app if in-memory access is sufficent

    For solution 1 (as Content file)

    • Mark the file in the Solution Explorer
    • Right click the file and select properties
    • Change the Build Action to Content

    Now the file is located in Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "license.txt").

    Maybe you added a folder in your solution directory and moved the wanted file there. In this case VS will create the whole structure as defined in your solution to lay down your content file. In that case you’ll probably need to add the folder information also to the code above.

    For solution 2 (as internal resource)

    • Add the wanted file (if not already happened) to your project (Project – Add Existing Item)
    • Double click within the Solution Explorer on MyProject – Properties – Resources.resx
    • Click on the little down arrow next to the Add Resource button and select Add Existing File …
    • Select the file you like again in the dialog

    Now the file is added as a internal resource to your project. To access it from code just use Properties.Resources.MyFileName. Depending of the kind of file you’ll get here a string (if it is a text only file) or a byte array (if it contains any non text).

    Also if it is a simple text file you can double click it in your Solution Explorer, edit it and after a rebuilt the new application contains the altered text (very handy if you need some SQL statements or XML files within your app).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.