Answer the question
In order to leave comments, you need to log in
Am I referring to the file by address correctly?
Am I accessing the file correctly?
StreamReader fr = new StreamReader("D:\\C# Projects\\ONU-Manager\\ONU-Manager\\bin\\Debug\\check.txt");
Answer the question
In order to leave comments, you need to log in
on the screenshot, one "ONU-Manager" is separated by a hyphen, the other is separated by a space.
In addition, use the syntax that will allow you to copy the path from the explorer
StreamReader fr = new StreamReader(@"D:\C# Projects\ONU-Manager\ONU Manager\bin\ debug\check.txt");
ps use as an example for reflection
using System;
using System.IO;
namespace mypath
{
class Program
{
static void Main(string[] args)
{
var p = Environment.CurrentDirectory;
Console.WriteLine(p);
Console.ReadKey();
p += @"\..\..\App.config";
var appcfg = File.ReadLines(p);
foreach(var l in appcfg)
Console.WriteLine(l);
Console.ReadKey();
}
}
}
Use the Path and AppDomain class:
Let's get the full path to the folder from which the program was launched and add our file there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question