Working directory in c sharp

A function in c sharp  to get working directory the programm

				
					        private string? GetWorkingdir()
        {
            string? tmpDir = "";
            try

            {
                string tmpDir1 = AppContext.BaseDirectory;
                if (Directory.Exists(tmpDir1))
                {
                    Console.WriteLine("dir exists   read file ??");
                    tmpDir = tmpDir1;
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex);
                tmpDir = null;
            }

            return tmpDir;
        }
				
			

1 thought on “Working directory in c sharp”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top