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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:38:13+00:00 2026-05-27T07:38:13+00:00

I’m having a problem opening a file in C#. I got a file which

  • 0

I’m having a problem opening a file in C#.
I got a file which I need to read and when I’m trying to open it using C#, for some reason file cannot be found.
Here is my code:

 string fullpath = Directory.GetCurrentDirectory() + 
                   string.Format(@"\FT933\FT33_1");
 try
 {
      StreamReader reader = new StreamReader(fullpath);
 }
 catch(Exception e)
 {
       Console.WriteLine("The file could not be read:");
       Console.WriteLine(e.Message);
 }

The file I’m trying to open is inside Debug\FT933\FT33_1 and got no extension.
Whenever I’m trying to open a text file from the same directory I manage to do so.

EDIT:

to be more it precise i think that problem that i have is that i dont know how to open a file that has no extentions (if i change the file to have .txt extention i do manage to open it)

  • 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-27T07:38:14+00:00Added an answer on May 27, 2026 at 7:38 am

    Don’t use hardcoded path or directories, but builtin functions to join paths.
    Try

    string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    string fullpath = Path.Combine(path, your_filename);
    

    And remember that current directory could not be your app’s one!.
    More, always include streams in using statement

    using(StreamReader reader = new StreamReader(fullpath))
    {
        // Do here what you need
    }
    

    so you’re sure it will be released when necessary not wasting memory!

    EDITED after OP comment:
    This is my working attempt:

    string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    string fullpath = Path.Combine(path, @"FT933\FT33_1");
    if (File.Exists(fullpath))
    {
        using (StreamReader reader = new StreamReader(fullpath))
        {
            string ret = reader.ReadLine();
        }
    }
    else
    {
        // File does not exists
    }
    

    If you fall in // File does not exists section, be sure that file is not where you’re searching for!
    Are you sure your file does not have an hidden extension?
    Are you sure OS or some app is not locking file for some reason?

    EDITED again after another comment:
    Open a command prompt (using Start->Run->CMD (enter) ) and run this command:

    dir "C:\Users\Stern\Documents\Visual Studio 2010\Projects\Engine\ConsoleApplication1\bin\Debug\FT933\*.*" /s
    

    and edit your question showing us result.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small

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.