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 8031275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:02:38+00:00 2026-06-05T01:02:38+00:00

I have code that reads encrypted credentials from a text file. I updated that

  • 0

I have code that reads encrypted credentials from a text file. I updated that text file to include a connection string. Everything else is read and decrypted fine, but not the connection string (naturally, I updated my code accordingly, too).

So I got to wondering: is it reading the correct file. The answer: No! The file in \bin\debug is dated 6/5/2012 9:41 am, but this code:

using (StreamReader reader = File.OpenText("Credentials.txt")) {
    string line = null;
    MessageBox.Show(File.GetCreationTime("Credentials.txt").ToString());

…shows 6/4/2012 2:00:44 pm

So I searched my hard drive for all instances of “Credentials.txt” to see where it was reading the file from. It only found one instance, the one with today’s date in \bin\debug.

???

Note: Credentials.txt is not a part of my solution; should it be? (IOW, I simply copied it into \bin\debug, I didn’t perform an “Add | Existing Item”)

  • 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-06-05T01:02:41+00:00Added an answer on June 5, 2026 at 1:02 am

    Provided you don’t change the current directory, the file in bin\Debug is going to be the one being read, as you’re not specifying a full path.

    The problem is likely due to the differences between the different File dates. The Creation Date (which is what you are fetching and displaying as 6/4 @ 2:00:44pm) is likely different from the Date modified (which is what is shown by default in Windows Explorer). This date can be fetched using File.GetLastWriteTime instead of GetCreationTime.

    That being said, I would recommend using the full path to the file, and not assuming that the current directory is the same as the executable path. Specifying the full path (which can be determined based on the executable path) will be safer, and less likely to cause problems later. This can be done via:

    var exePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
    var file = System.IO.Path.Combine(exePath, "Credentials.txt");
    using (StreamReader reader = File.OpenText(file)) { // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some C# code that reads data from a text file using a
In my .aspx.cs I have a code that reads a .xml file and I
I have the following code that reads the content of a url public static
I have a file that was encrypted using AES. I use the following NSData
I have some text that is in a file. I want to encrypt this
I have an application that reads a CSV file with piles of data rows.
I have been tasked with decrypting a file in Java that has been encrypted
I am trying to decrypt a String, that I have encrypted elsewhere. Here is
I have some jQuery code that intercepts links clicked on a page: $(document).ready(function() {
I have android.permission.READ_OWNER_DATA but I can't find any reliable code that would explain how

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.