Search code examples
c#.netc#-4.0fileinfo

How fileinfo takes the path when I do not specify a particular path in c#


Here is my code

private const string abc="demo.sql";
var fileinfo = new fileInfo(abc);

I want to know how fileInfo will read the path, I mean directory path when I do not specify any path for .sql file. I have placed sql file in some other folder in c# project, wanted to know how I can read the path of this folder


Solution

  • It will assume the path is the executing directory of where the application is run from..

    The variable fileinfo would have the following properties and values, if the executing directory of your application was C:\Program Files(x86)\LINQPad5

    enter image description here

    You'll notice that the Exists property is False, because there is no file called demo.sql in the aforementioned directory.